问题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.youkuaiyun.com/coolsoloist/article/details/106425656
附录:
1.Rust环境搭建
https://www.runoob.com/rust/rust-setup.html
2.使用Rust创建新项目
https://blog.youkuaiyun.com/weixin_28934777/article/details/112286569
当使用Cargo构建Rust项目时遇到'linker link.exe not found'错误,通常是由于缺少Visual Studio的C++生成工具。解决方法是安装Visual Studio 2019 Build Tools,确保选择'MSVC v142 - VS2019 C++ x64/x86生成工具'。参考提供的博客链接进行详细操作。
2303





