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!

相关推荐
爱分享的阿Q1 小时前
Rust加WebAssembly前端性能革命实践指南
前端·rust·wasm
沉淀粉条形变量8 小时前
rust 单例模式
开发语言·单例模式·rust
skilllite作者10 小时前
SkillLite 多入口架构实战:CLI / Python SDK / MCP / Desktop / Swarm 一页理清
开发语言·人工智能·python·安全·架构·rust·agentskills
Rust研习社10 小时前
深入理解 Rust 闭包:从基础语法到实战应用
rust
Rust研习社10 小时前
Rust 时间处理神器:chrono 从入门到实战
rust
Rust研习社11 小时前
Rust 异步 ORM 新选择:Toasty 初探
rust
星辰徐哥11 小时前
异步定时任务系统的设计与Rust实战集成
开发语言·后端·rust
swear0112 小时前
【VSCODE 插件 rust-analyzer 使用】打开文件夹
ide·vscode·rust
laomocoder12 小时前
AI网关设计
人工智能·rust·系统架构
zandy101113 小时前
业界首发|衡石科技HENGSHI CLI重磅登场,以Rust架构开启Agentic BI自动驾驶时代
科技·架构·rust·agentic bi