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!

相关推荐
浪客川28 分钟前
【百例RUST - 010】字符串
开发语言·后端·rust
好家伙VCC7 小时前
# 发散创新:用 Rust实现高性能物理引擎的底层架构设计与实战在游戏开发、虚拟仿真和机器人控
java·开发语言·python·rust·机器人
代码羊羊8 小时前
Rust所有权与引用:核心要点速记
rust
浪客川10 小时前
【百例RUST - 009】容器 Vector
开发语言·rpc·rust
Rust研习社11 小时前
Rust Default 特征详解:轻松实现类型默认值
开发语言·后端·rust
Rust研习社11 小时前
Rust Copy 特征详解|新手必看!再也不与 Clone 混淆
后端·rust·编程语言
Source.Liu13 小时前
【Matrix】Matrix 开源 Rust 项目全景
rust·开源
浪客川14 小时前
【百例RUST - 011】简单键值对
开发语言·后端·rust
techdashen1 天前
Rust项目公开征测:Cargo 构建目录新布局方案
开发语言·后端·rust