Avatar ·

Windows 中 Rust 编译错误:linker `link.exe` not found

大家好!我刚开始学习 Rust,决定编写我的第一个程序 "Hello, world!"。通过官方安装程序 `rustup-init.exe` 安装了 Rust,一切顺利。使用 `cargo new hello_world` 创建了一个新项目,进入文件夹后,尝试用 `cargo build` 命令编译最简单的代码时,出现以下错误: ``` error: linker `link.exe` not found | = note: 程序无法启动:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\link.exe" = help: 确保 Visual Studio 工具路径已添加到 PATH 环境变量中。 ``` 这是我的代码(`main.rs` 文件): ```rust fn main() { println!("Hello, world!"); } ``` 我使用的是 Windows 11,Rust 版本为 1.76.0。我没有安装 Visual Studio Community 2022,原以为 Rust 自带所有必需组件。是否需要额外安装什么?我尝试过重启电脑,但问题依旧。请告诉我如何解决。