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!

相关推荐
m0_480502646 小时前
Rust 入门 KV存储HashMap (十七)
java·开发语言·rust
Include everything9 小时前
Rust学习笔记(三)|所有权机制 Ownership
笔记·学习·rust
码码哈哈爱分享11 小时前
Tauri 框架介绍
css·rust·vue·html
寻月隐君1 天前
硬核实战:从零到一,用 Rust 和 Axum 构建高性能聊天服务后端
后端·rust·github
m0_480502641 天前
Rust 入门 泛型和特征-特征对象 (十四)
开发语言·后端·rust
RustFS2 天前
如何用 Rust 对 RustFS MCP Server 进行扩展?
rust
我是前端小学生4 天前
一文梳理Rust语言中的可变结构体实例
rust
Source.Liu4 天前
【unitrix数间混合计算】2.21 二进制整数加法计算(bin_add.rs)
rust
Include everything4 天前
Rust学习笔记(二)|变量、函数与控制流
笔记·学习·rust
Source.Liu4 天前
【unitrix数间混合计算】2.20 比较计算(cmp.rs)
rust