win10下我的第一個rust程序的編譯及運行


新建一個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!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM