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!

相关推荐
维维酱2 小时前
Rust - 互斥锁
rust
维维酱2 小时前
Rust - 共享状态的并发
rust
ArcX4 小时前
从 JS 到 Rust 的旅程
前端·javascript·rust
Humbunklung4 小时前
Rust Floem UI 框架使用简介
开发语言·ui·rust
寻月隐君9 小时前
深入解析 Rust 的面向对象编程:特性、实现与设计模式
后端·rust·github
KENYCHEN奉孝1 天前
基于 actix-web 框架的简单 demo
前端·rust
love530love1 天前
【笔记】旧版MSYS2 环境中 Rust 升级问题及解决过程
开发语言·人工智能·windows·笔记·python·rust·virtualenv
Humbunklung1 天前
Rust 函数
开发语言·后端·rust
荣江1 天前
【实战】基于 Tauri 和 Rust 实现基于无头浏览器的高可用网页抓取
后端·rust
susnm1 天前
创建你的第一个 Dioxus app
rust·全栈