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!

相关推荐
DevOps00810 小时前
在 Azure Linux 上安装 RustFS
rust·minio·分布式存储·s3·rustfs
hweiyu0010 小时前
Rust 简介
rust
萧曵 丶10 小时前
Rust中Option和Result详解
开发语言·后端·rust·option·result
火柴就是我14 小时前
每日见闻之Rust中 trait 的孤儿规则
android·rust
zstar-_20 小时前
Hello, Tauri!
rust
我是前端小学生1 天前
Rust中的Vec数据结构介绍
rust
小马哥聊DevSecOps2 天前
RustFS:Rust 语言编写的分布式存储系统初探
rust
UestcXiye2 天前
Rust Web 全栈开发(八):添加功能并重构
rust·actix
UestcXiye2 天前
Rust Web 全栈开发(六):在 Web 项目中使用 MySQL 数据库
数据库·rust
UestcXiye3 天前
Rust Web 全栈开发(五):使用 sqlx 连接 MySQL 数据库
数据库·mysql·rust