嵌入式 Rust 修炼营:win10安装rust +mingw64
[复制链接]
1.基础介绍
参加此次活动,主要原因是之前学习rust从入门到放弃,没有一个实战的小项目,于是可以通过这次机会,结合嵌入式小板子学习rust。主要是windows上使用,可能会比较麻烦,因此参考了很多贴子。搭建前需要准备 安装vscode 、配置mingw64[ ]或者msvc [vs_build_tool.exe]【mingw64和msvc 二选一即可 安装过程以mingw64为例 】
x86_64-14.2.0-release-posix-seh-ucrt-rt_v12-rev1.7z 版本选最新的就行 win上使用标红版本较好。下载后大概79M,解压到自己常用文件夹 ,并添加到环境变量中 [D:\Program Files (x86)\mingw64\bin] 比较轻量级。msvc 下载完3G左右文章最后有示例。
2.安装
2.1 安装rust
配置用户环境变量
RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
CARGO_HOME D:\rust\cargo_home
RUSTUP_HOME D:\rust\rust_home
下载rustup-init.exe[ rust官网]选择Download rustup-init.exe (64-bit)
下载完成执行,因为此次需要使用mingw64 作为rust的c++环境,rust在win上的安装程序默认是msvc,需要选择3 后续设置c++环境;
进入了安装流程,rust会识别到 刚才配置的rust 环境变量
default的还是只用 msvc 选择2 自定义
手动修改 【x86_64-pc-windows-gnu】
后续的配置直接回车使用defult, 最后一个直接回车
- Current installation options:
-
- default host triple: x86_64-pc-windows-gnu
- default toolchain: stable
- profile: default
- modify PATH variable: yes
-
- 1) Proceed with selected options (default - just press enter)
- 2) Customize installation
- 3) Cancel installation
- >1
- info: profile set to 'default'
- info: setting default host triple to x86_64-pc-windows-gnu
- info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
- info: latest update on 2025-03-18, rust version 1.85.1 (4eb161250 2025-03-15)
- info: downloading component 'cargo'
- 10.8 MiB / 10.8 MiB (100 %) 3.2 MiB/s in 3s
- info: downloading component 'clippy'
- 4.4 MiB / 4.4 MiB (100 %) 2.7 MiB/s in 2s
- info: downloading component 'rust-docs'
- 16.8 MiB / 16.8 MiB (100 %) 3.3 MiB/s in 6s
- info: downloading component 'rust-mingw'
- 5.2 MiB / 5.2 MiB (100 %) 2.7 MiB/s in 2s
- info: downloading component 'rust-std'
- 27.3 MiB / 27.3 MiB (100 %) 3.4 MiB/s in 9s
- info: downloading component 'rustc'
- 84.7 MiB / 84.7 MiB (100 %) 3.4 MiB/s in 26s
- info: downloading component 'rustfmt'
- 3.4 MiB / 3.4 MiB (100 %) 1007.3 KiB/s in 2s
- info: installing component 'cargo'
- info: installing component 'clippy'
- info: installing component 'rust-docs'
- 16.8 MiB / 16.8 MiB (100 %) 3.6 MiB/s in 2s
- info: installing component 'rust-mingw'
- info: installing component 'rust-std'
- 27.3 MiB / 27.3 MiB (100 %) 18.7 MiB/s in 1s
- info: installing component 'rustc'
- 84.7 MiB / 84.7 MiB (100 %) 19.4 MiB/s in 4s
- info: installing component 'rustfmt'
- info: default toolchain set to 'stable-x86_64-pc-windows-gnu'
-
- stable-x86_64-pc-windows-gnu installed - rustc 1.85.1 (4eb161250 2025-03-15)
-
-
- Rust is installed now. Great!
-
- To get started you may need to restart your current shell.
- This would reload its PATH environment variable to include
- Cargo's bin directory (D:\rust\cargo_home\bin).
-
- Press the Enter key to continue.
安装完成后 查看基本信息、版本信息
安装前如果不想使用mingw64 或不想安装完整的vs 可以去下载msvc c++ 生成工具[vs_build_tool.exe]
下载运行后,勾选c++工具
右侧的安装固件有点多 可以去掉cmake ; cmake【 】 可以自己下载解压缩 并配置到环境变量中
接着在语言处选择加上英文,修改文件安装位置,
这个配置ok之后 再从2.1 开始按装rust , 基本上可以一路回车安装了
|