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!

相关推荐
吴佳浩6 小时前
AI Infra 的真相:Go 没输,rust也不是取代
后端·rust·go
mit6.82411 小时前
并发协调的代价
rust
不爱学英文的码字机器14 小时前
[鸿蒙PC命令行移植适配]移植rust三方库sd到鸿蒙PC的完整实践
华为·rust·harmonyos
星栈14 小时前
Makepad 不只是画界面:事件、状态和组件通信,到底怎么写
前端·rust
绍磊leo14 小时前
Tauri 2.x 教程系列 (二):React 组件化与 Tauri 命令系统
rust·tauri
日火15 小时前
Are Mutexes Slow——互斥锁真的慢吗?
性能优化·rust
禁默15 小时前
[鸿蒙PC命令行移植适配]移植rust三方库eza到鸿蒙PC的完整实践
华为·rust·harmonyos
绍磊leo15 小时前
Tauri 2.x 教程系列 (一):Hello Tauri — 从零搭建第一个桌面应用
rust·tauri
smallswan15 小时前
第十七 位运算
rust
a诠释淡然1 天前
C++ vs Rust:哪个更适合你的下一个项目?
开发语言·c++·rust