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!

相关推荐
传奇开心果编程11 小时前
【Rust入门知识点学与练】第24课:Trait 基础
开发语言·学习·rust
传奇开心果编程1 天前
【dioxus0.7基础语法学与练】第8课:RSX 宏 — Dioxus 声明式 UI 语法
开发语言·学习·rust
柯南46681 天前
【AI开发之Rust】第 5 课:引用与生命周期 —— 借用能活多久?
rust
码农哈丁1 天前
从 JVM 到 Cargo:把整个 Kotlin 项目移植到 Rust 的踩坑实录
jvm·rust·kotlin
PC2005-cloud1 天前
Rust学习笔记:所有权、借用与生命周期——Rust的核心机制
笔记·学习·rust
Amos_Web1 天前
Rspack 源码解析(四):从 ModuleGraph 到 ChunkGraph
rust·源码阅读
传奇开心果编程1 天前
【xilem0.4基础语法学与练】第45课 xilem_core
学习·rust·前端框架
芒鸽1 天前
把 Agent 运行时做成插件系统:agent-harness(openJiuwen Rust版) 的实践
开发语言·后端·rust