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!

相关推荐
星释19 分钟前
Rust 练习册 57:阿特巴什密码与字符映射技术
服务器·算法·rust
星释8 小时前
Rust 练习册 44:Trait 中的同名函数调用
开发语言·后端·rust
朝九晚五ฺ8 小时前
深入Rust标准库(std):核心能力与实战指南
开发语言·后端·rust
2013编程爱好者8 小时前
Rust变量
开发语言·后端·rust
yezipi耶不耶11 小时前
Cloudflare 11.18 故障深度复盘:当“极致优化”撞上“现实边界“
rust·web
星释11 小时前
Rust 练习册 60:鲍勃与字符串处理的状态机思维
开发语言·网络·rust
s91236010112 小时前
【Openwrt】M4 Macmini编译Openwrt的Dockerfile
rust
星释13 小时前
Rust 练习册 21:Hello World 与入门基础
开发语言·后端·rust
Damon小智14 小时前
深入浅出Rust编程:Vec 源码解析
rust
星释16 小时前
Rust 练习册 32:二分查找与算法实现艺术
开发语言·算法·rust