Rust报错:the msvc targets depend on the msvc linker but `link.exe` was not found

当我在我的 windows 电脑上安装 rust,然后用 cargo 新建了一个项目后,cargo run 会报错:

shell 复制代码
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: could not compile `minigrep` (bin "minigrep") due to previous error

这个报错是 C 的编译器引起的,这里我见到了几种常见的解决方法(我用最后一种方法成功解决了问题):

  1. 下载安装 Visual Studio 2019 的构建工具,但是显然,下一个这玩意需要很大内存。但是这种方法确实是比较正宗的解决方法,一般不会有幺蛾子。记得选C++ 工具

  2. 这个错误可能是因为使用GCC编译,需要顺序执行,修复一下:

    • 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
  3. Microsoft C++ 生成工具 安装一下,记得选上下面这几个

  4. 这种方法最简单,因为不用安装很多东西占很多内存,也没有繁琐的步骤:

    直接执行:
    rustup default stable-x86_64-pc-windows-gnu

相关推荐
Ulyanov5 小时前
高保真单脉冲雷达导引头回波生成:Python建模与实践
开发语言·python·仿真·系统设计·单脉冲雷达
阿猿收手吧!5 小时前
【C++】jthread:优雅终止线程新方案
开发语言·c++
lly2024066 小时前
《JavaScript 实例》
开发语言
十五年专注C++开发6 小时前
C++中各平台表示Debug的宏
开发语言·c++·debug
张小凡vip6 小时前
Python异步编程实战:基于async/await的高并发实现
开发语言·python
玩c#的小杜同学6 小时前
源代码保卫战:给C# 程序(混淆、加壳与反逆向实战)
开发语言·笔记·c#
阿猿收手吧!8 小时前
【C++】Ranges:彻底改变STL编程方式
开发语言·c++
云游云记8 小时前
php 随机红包数生成
开发语言·php·随机红包
程序员林北北8 小时前
【前端进阶之旅】JavaScript 一些常用的简写技巧
开发语言·前端·javascript
0xSec笔记本挖呀瓦呀挖9 小时前
Windows后门应急(二)--计划任务后门分析与处置|Windows取证分析
windows·安全·web安全·网络安全·系统安全·网络攻击模型·安全威胁分析