新建一個rust程序 main.rs
,內容如下:
fn main() {
println!("hello,world!");
}
命令行運行 rustc main.rs
報錯如下:
> rustc .\main.rs
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
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option
error: aborting due to previous error
解決辦法是去必應搜索“Download Visual C++ Build Tools”,然后下載最新版本的 Visual C++ Build Tools 並安裝即可。
我的下載鏈接是:https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/
安裝好后執行 rustc main.rs
會在當前目錄生成一個 main.exe
文件,執行 .\main.exe
就能看到程序運行的結果了:
> .\main.exe
hello,world!