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!

相关推荐
Rust研习社6 小时前
添加依赖库时的 features 是什么?优雅实现编译期条件编译与模块化开发
开发语言·后端·rust
Rust研习社7 小时前
Rust 条件变量(Condvar)详解:线程同步的高效方式
后端·rust·编程语言
Rust研习社7 小时前
Rust Channel 详解:线程间安全通信的利器
后端·rust·编程语言
Source.Liu12 小时前
【A11】身份证号无损压缩到48位的Rust实现
rust
圆山猫14 小时前
[RISCV] 用 Rust 写一个 RISC-V BootROM:从 QEMU 到真实硬件(2)
rust·risc-v
Rust研习社1 天前
Once、OnceCell、OnceLock:Rust 一次性初始化终极指南
后端·rust·编程语言
Rust研习社1 天前
从入门到实践:Rust 异步编程完全指南
开发语言·后端·rust
Rust研习社1 天前
Rust Pin 解析:核心原理与异步编程实践
开发语言·后端·rust
圆山猫1 天前
[AI] [Linux] 教我编一个启用rust的riscv kernel用于qemu启动
linux·ai·rust
代码羊羊1 天前
Rust-特征trait和特征对象
服务器·网络·rust