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