无法在 Windows 上编译 Rust hello world:找不到链接器 link.exe [英] Unable to compile Rust hello world on Windows: linker link.exe not found

查看:96
本文介绍了无法在 Windows 上编译 Rust hello world:找不到链接器 link.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从 Rust 安装页面在 Windows 上安装了 Rust.安装后,我尝试运行hello world"程序,但出现以下错误.

I have installed Rust on windows from Rust installation page. After installation I tried running the "hello world" program but got the following error.

>cargo run

错误

Compiling helloworld v0.1.0 (C:UsersDELLhelloworld)

error: linker `link.exe` not found
note: The system cannot find the file specified. (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 or VS 2017 was installed with the Visual C++ option
error: aborting due to previous error
error: Could not compile `helloworld`.

To learn more, run the command again with --verbose.

代码:

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

推荐答案

我下载并安装了 Visual Studio 2019 的构建工具.在安装过程中,我选择了 C++ 工具.它下载了近 5GB 的数据.我在安装和编译代码后重新启动机器工作正常:

I downloaded and installed the Build Tools for Visual Studio 2019. During installation I selected the C++ tools. It downloaded almost 5GB of data. I restarted the machine after installation and compiling the code worked fine:

> cargo run
Compiling helloworld v0.1.0 (C:UsersDELLhelloworld)
Finished dev [unoptimized + debuginfo] target(s) in 12.05s
  Running `targetdebughelloworld.exe`
Hello, world!

这篇关于无法在 Windows 上编译 Rust hello world:找不到链接器 link.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆