win10下我的第一个rust程序的编译及运行

新建一个rust程序 main.rs ,内容如下:

fn main() { println!("hello,world!");}

命令行运行 rustc main.rs 报错如下:

> rustc .\main.rserror: linker `link.exe` not found | = note: 系统找不到指定的文件。 (os error 2)note: the msvc targets depend on the msvc linker but `link.exe` was not foundnote: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ optionerror: 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.exehello,world!

相关文章