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!

相关推荐
yezipi耶不耶7 小时前
Rust入门之高级Trait
开发语言·后端·rust
后青春期的诗go7 小时前
基于Rust语言的Rocket框架和Sqlx库开发WebAPI项目记录(一)
开发语言·后端·rust
景天科技苑8 小时前
【Rust闭包】rust语言闭包函数原理用法汇总与应用实战
开发语言·后端·rust·闭包·闭包函数·rust闭包·rust闭包用法
欧先生^_^8 小时前
rust语言,与c,go语言一样也是编译成二进制文件吗?
c语言·golang·rust
明月看潮生19 小时前
青少年编程与数学 02-019 Rust 编程基础 14课题、并发编程
开发语言·青少年编程·rust·编程与数学
明月看潮生20 小时前
青少年编程与数学 02-019 Rust 编程基础 07课题、字符串
开发语言·青少年编程·rust·编程与数学
明月看潮生1 天前
青少年编程与数学 02-019 Rust 编程基础 13课题、智能指针
开发语言·青少年编程·rust·编程与数学
Python私教2 天前
征服Rust:从零到独立开发的实战进阶
服务器·开发语言·rust
Python私教2 天前
Rust:重新定义系统编程的安全与效率边界
开发语言·安全·rust
明月看潮生2 天前
青少年编程与数学 02-019 Rust 编程基础 12课题、所有权系统
开发语言·青少年编程·rust·编程与数学