官网地址

https://www.rust-lang.org/


安装

下载安装文件

https://www.rust-lang.org/tools/install

安装

点开后进入命令行界面,过程中会安装多个工具集

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-pc-windows-msvc
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
699.0 KiB / 699.0 KiB (100 %) 189.5 KiB/s in  4s ETA:  0s
info: latest update on 2023-10-05, rust version 1.73.0 (cc66ad468 2023-10-03)
info: downloading component 'cargo'
  5.6 MiB /   5.6 MiB (100 %)  66.2 KiB/s in  1m 25s ETA:  0s
info: downloading component 'clippy'
  2.2 MiB /   2.2 MiB (100 %)  72.6 KiB/s in 44s ETA:  0s
info: downloading component 'rust-docs'
 13.8 MiB /  13.8 MiB (100 %)  64.8 KiB/s in  3m 13s ETA:  0s
info: downloading component 'rust-std'
 20.5 MiB /  20.5 MiB (100 %)  79.0 KiB/s in  4m 49s ETA:  0s
info: downloading component 'rustc'
 59.0 MiB /  59.0 MiB (100 %) 101.4 KiB/s in 12m 27s ETA:  0s
info: downloading component 'rustfmt'
  1.6 MiB /   1.6 MiB (100 %)  82.2 KiB/s in 19s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 13.8 MiB /  13.8 MiB (100 %)   1.5 MiB/s in 14s ETA:  0s
info: installing component 'rust-std'
 20.5 MiB /  20.5 MiB (100 %)   9.8 MiB/s in 40s ETA:  0s
info: installing component 'rustc'
 59.0 MiB /  59.0 MiB (100 %)  10.5 MiB/s in  5s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc installed - rustc 1.73.0 (cc66ad468 2023-10-03)


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 (%USERPROFILE%\.cargo\bin).


vscode

https://code.visualstudio.com/docs/languages/rust


error: linker `link.exe` not found

error: linker `link.exe` not found
  |
  = note: program not found

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

note: VS Code is a different product, and is not sufficient.

error: could not compile `hello-world` (bin "hello-world") due to previous error

这是说明没有微软MS VC++编译环境的链接程序linker.exe,需要VC++ 2013或及以后版本的VC++编译器,

方式一

安装Virual Studio,然后安装C++生成工具

方式二

(试过,没效果)

rustup toolchain install stable-x86_64-pc-windows-gnu

执行完后,执行下面命令

rustup default stable-x86_64-pc-windows-gnu

参考  https://blog.csdn.net/Libigtong/article/details/131823204