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!

相关推荐
@大迁世界3 分钟前
告别 Go,拥抱 Rust
开发语言·golang·rust
低调滴开发1 小时前
3 行代码写崩一个函数?切片才是 Rust 字符串处理的正确姿势
开发语言·后端·rust
小灰灰搞电子4 小时前
Rust+Slint 实现高级动态消息提示框源码分享
开发语言·rust
qq_406981034 小时前
大白话rust系列08 当变量遮蔽遇上引用,探究变量遮蔽的本质
开发语言·后端·rust
轻舟技术A6 小时前
Pi、rpi、Pi-Bolt 重测:rpi 在启动、内存与读取上全面领先
人工智能·rust
用户14498433464756 小时前
我为什么做一个开源的 Mac 清理工具
rust
古城小栈9 小时前
Rust 学习路线,供初学者参考
开发语言·rust
小熊吃保安1 天前
Windows也能用 Apple Watch 解锁
windows·rust·开源
离歌漠2 天前
《我用 Tauri 做了一个本地开发工具箱》
rust·typescript·vue