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!

相关推荐
今日说"法"8 小时前
Rust探秘:所有权转移在函数调用中的表现
开发语言·后端·rust
G_dou_11 小时前
rust:第一个程序HelloWorld
rust
G_dou_13 小时前
Rust安装
开发语言·后端·rust
初学者,亦行者14 小时前
Rust性能优化:内存对齐与缓存友好实战
算法·rust
微知语15 小时前
悬垂引用的攻防战:Rust 如何从根源杜绝内存访问灾难
开发语言·算法·rust
想不明白的过度思考者15 小时前
Rust——或模式(Or Patterns)的语法:Rust模式匹配的优雅演进
开发语言·后端·rust·模式匹配
绵绵细雨中的乡音15 小时前
深入理解 Rust 的 LinkedList:双向链表的实践与思考
开发语言·链表·rust
oioihoii15 小时前
Rust 中 LinkedList 的双向链表结构深度解析
开发语言·链表·rust
大鱼七成饱16 小时前
十分钟掌握 Rust json 序列化工具
rust·json
Source.Liu16 小时前
【PrintPDF】PrintPDF Cargo.toml 分析
rust·pdf