我从Rust installation page年前就开始在windows 上安装铁 rust .安装后,我try 运行"hello world"程序,但出现以下错误.

>cargo run

Error

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.

Code:

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

推荐答案

我下载并安装了Build Tools for Visual Studio 2019.在安装过程中,我 Select 了C++ tools.它下载了近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!

Rust相关问答推荐

如何优化小型固定大小数组中的搜索?

为什么类型需要在这个代码中手动指定,在rust?

如何访问Rust存储值的内存地址

如何编写一个以一个闭包为参数的函数,该函数以另一个闭包为参数?

如何在Rust中将选项<;选项<;字符串>;转换为选项<;选项&;str>;?

Rust&;Tokio:如何处理更多的信号,而不仅仅是SIGINT,即SIGQUE?

我如何制作一个变异迭代器来锁定内部数据直到删除?

JSON5中的变量类型(serde)

无法实现整型类型的泛型FN

在 Rust 中用问号传播错误时对类型转换的困惑?

在使用粗粒度锁访问的数据 struct 中使用 RefCell 是否安全?

为什么 Rust 字符串没有短字符串优化 (SSO)?

如何获取模块树?

为什么这段 Rust 代码会在没有递归或循环的情况下导致堆栈溢出?

在 Rust 中,我如何处理请求 javascript 的页面?

为什么 for_each 在释放模式(cargo run -r)下比 for 循环快得多?

有没有办法隐藏类型定义?

当引用不再被borrow 时,Rust 不会得到它

为什么 Rust 中的关联类型需要明确的生命周期注释?

为什么一个整型变量赋值给另一个变量后仍然可以使用?