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!

相关推荐
敬业小码哥3 小时前
记一次:clion使用rust插件配置环境并开发
学习·rust
NGINX开源社区6 小时前
NGINX 引入对 ACME 协议的原生支持
nginx·rust
Rust语言中文社区7 小时前
【Rust日报】 CEL与Rust实现接近原生速度的解释执行
开发语言·后端·rust
FreeBuf_9 小时前
恶意Rust组件与AI机器人利用CI/CD管道窃取开发者密钥
人工智能·ci/cd·rust
水月wwww21 小时前
Rust的安装与卸载 | windows
开发语言·windows·rust
Mem0rin1 天前
[自用]Rust速通day5:包、crate和use
rust
Ivanqhz1 天前
活跃范围重写(Live Range Rewriting)
开发语言·c++·后端·算法·rust
Roc.Chang1 天前
Rust 入门 - RustRover 新建项目时四种项目模板对比
开发语言·后端·rust
勇敢牛牛_2 天前
【conreg-client】在Rust中使用向Feign一样的远程调用
网络·rust·feign
小杍随笔2 天前
【Rust模块化进阶:深入解析mod.rs的用法与现代实践(1.94版本)】
开发语言·后端·rust