或者是报错如下:
cargo run
Compiling hello-rust v0.1.0 (D:\gantStudyDemo\hello-rust)
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.
错误原因
这个错误表明编译Rust程序时没有找到MSVC linker,需要通过安装Visual Studio 2017或更高版本或Visual Studio Build Tools解决该问题。这是因为Rust编译器通常使用Microsoft的C++编译器来编译Rust程序。
可以按照以下步骤来解决该问题:(不推荐用下面的方式)
访问Rust官方网站下载安装 Rust。
通过Rust官方指南中的步骤,检查您的安装是否成功。
如果您没有安装Visual Studio或Build Tools,则需要 下载并安装 Visual Studio 2017或更高版本 或 Build Tools for Visual Stu