无法在Windows上编译Rust hello world:找不到链接器link.exe

问题描述 投票:4回答:1

我在Rust installation page的窗户上安装了Rust。安装后我尝试运行“hello world”程序,但出现以下错误。

>cargo run

错误

Compiling helloworld v0.1.0 (C:\Users\DELL\helloworld)

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!");
}
compiler-errors installation rust linker-errors build-tools
1个回答
11
投票

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

> cargo run
Compiling helloworld v0.1.0 (C:\Users\DELL\helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 12.05s
  Running `target\debug\helloworld.exe`
Hello, world!
© www.soinside.com 2019 - 2024. All rights reserved.