在Windows 10的WSL上使用Debian编译Rust时出现错误 "linker 'cc' not found"
大家好!我是Rust新手,使用安装了WSL子系统(Debian)的Windows 10。当我尝试编译最简单的程序时,遇到了这个错误。
这是我的代码(main.rs文件):
```rust
fn main() {
println!("Hello, world!");
}
```
我在WSL(Debian)终端中运行 `rustc main.rs` 或 `cargo build`,然后收到消息:
```
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
```
Rust是通过 `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` 安装的,一切顺利。`rustc --version` 显示版本为1.70.0。但编译器找不到linker。
我已经搜索过,但大多数建议是针对纯Linux,而不是WSL。尝试过 `sudo apt update && sudo apt install build-essential` — 没有帮助。可能是因为WSL看不到Windows中安装的工具?还是需要在Rust中额外配置什么?
请告诉我如何专门针对Debian修复这个错误。