error: linker `link.exe` not found | = note: 系统找不到指定的文件。

当使用Cargo构建Rust项目时遇到'linker link.exe not found'错误,通常是由于缺少Visual Studio的C++生成工具。解决方法是安装Visual Studio 2019 Build Tools,确保选择'MSVC v142 - VS2019 C++ x64/x86生成工具'。参考提供的博客链接进行详细操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题1:出现报错“error: linker link.exe not found
|
= note: 系统找不到指定的文件。 (os error 2)”

PS C:\Users\sun\Desktop\runoob-greeting> cd .\greeting
PS C:\Users\sun\Desktop\runoob-greeting\greeting> cargo build
Compiling greeting v0.1.0 (C:\Users\sun\Desktop\runoob-greeting\greeting)
error: linker link.exe not found
|
= note: 系统找不到指定的文件。 (os error 2)
note: the msvc targets depend on the msvc linker but link.exe was not found

问题背景出现在:Rust 的构建工具和包管理工具 - Cargo

解决办法:
安装Visual Studio 2019 生成工具Visual Studio 2019 build tools或者微软Visual Studio。下载build tools之后,在Visual studio installer中只选择“C++生成工具”,然后只选择"MSVC v142 - VS2019 C++ x64/x86 生成工具"。
具体流程和下载地址参考博客:https://blog.csdn.net/coolsoloist/article/details/106425656

附录:
1.Rust环境搭建
https://www.runoob.com/rust/rust-setup.html
2.使用Rust创建新项目
https://blog.csdn.net/weixin_28934777/article/details/112286569

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值