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!

相关推荐
alwaysrun3 小时前
Rust中所有权和作用域及生命周期
rust·生命周期·作用域·所有权·引用与借用
FleetingLore19 小时前
Rust | str 常用方法
rust
一只小松许️2 天前
深入理解 Rust 的内存模型:变量、值与指针
java·开发语言·rust
m0_480502643 天前
Rust 登堂 之 Cell 和 RefCell(十二)
开发语言·后端·rust
烈风3 天前
011 Rust数组
开发语言·后端·rust
Dontla4 天前
Turbopack介绍(由Vercel开发的基于Rust的高性能前端构建工具,用于挑战传统构建工具Webpack、vite地位)Next.js推荐构建工具
前端·rust·turbopack
开心不就得了5 天前
构建工具webpack
前端·webpack·rust
ftpeak5 天前
《WebAssembly指南》第九章:WebAssembly 导入全局字符串常量
开发语言·rust·wasm
红烧code6 天前
【Rust GUI开发入门】编写一个本地音乐播放器(15. 记录运行日志)
rust·gui·log·slint
JordanHaidee6 天前
【Rust GUI开发入门】编写一个本地音乐播放器(15. 记录运行日志)
rust