error: linker `link.exe` not found

开始学习rust,安装好rust的环境,开始从hello world开始,结果用在win10环境下,使用vs code或cmd窗口编译rust报错:

rust 复制代码
PS E:\study_codes\rust-demo\chart01> rustc hello.rs
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: aborting due to 1 previous error

vs code或cmd窗口中运行以下命令即可解决:

bash 复制代码
rustup uninstall toolchain stable-x86_64-pc-windows-msvc
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu

运行rust编译命令:

rust 复制代码
rustc hello.rs
.\hello.exe

生成一个hello.exe文件

运行结果:

hello world

Have fun learning about rust!

相关推荐
shimly12345617 小时前
(done) 速通 rustlings(9) 分支跳转
rust
shimly1234561 天前
(done) 速通 rustlings(4) 变量声明
rust
shimly1234561 天前
(done) 速通 rustlings(11) 向量vector及其操作
rust
shimly1234561 天前
(done) 速通 rustlings(3) intro1 println!()
rust
shimly1234561 天前
(done) 速通 rustlings(12) 所有权
rust
shimly1234561 天前
(done) 速通 rustlings(7) 全局变量/常量
rust
敲敲了个代码1 天前
构建工具的第三次革命:从 Rollup 到 Rust Bundler,我是如何设计 robuild 的
开发语言·前端·javascript·后端·rust
lpfasd1231 天前
Tauri 中实现自更新(Auto Update)
rust·tauri·update
shimly1234561 天前
(done) 速通 rustlings(10) 基本数据类型
rust
shimly1234561 天前
(done) 速通 rustlings(8) 函数
rust