如何修复 Windows 10 上 Debian 的 Rust 错误"linker 'cc' not found"?



我在Windows 10(Linux的Windows子系统(上运行Debian,并使用以下命令安装了Rust:

curl https://sh.rustup.rs -sSf | sh

安装中没有错误,但是当我尝试使用rustc进行编译时,我得到了错误linker 'cc' not found

Linux Rust 安装程序不会检查编译器工具链,但似乎假设您已经安装了 C 链接器!最好的解决方案是安装久经考验的 gcc 工具链。

sudo apt install build-essential

如果需要面向其他体系结构,请安装相应的工具链并面向编译,如下所示:

rustc --target=my_target_architecture -C linker=target_toolchain_linker my_rustfile.rs

我运行了以下 2 个命令,它起作用了。

sudo apt-get update
sudo apt install build-essential

你必须安装一些依赖项

对于 Arch Linux:sudo pacman -S base-devel

对于 Ubuntu:sudo apt install build-essential

对于 Centos:sudo yum install gcc

对于索卢斯:sudo eopkg it -c system.devel

CentOS 的解决方案:

yum -y install gcc

如果你在WSL2 - Ubuntu上,尝试使用以下cmd更新pacakges:

sudo apt-get update
sudo apt install build-essential

我在 wsl1 中运行了以下命令,它有效

sudo apt-get update
sudo apt install build-essential

Solus 的解决方案:

sudo eopkg it -c system.devel

请在安装安装工具之前进行"更新和升级"。

您可以通过在 Linux 中添加构建基本包来解决此问题

sudo apt install -y build-essential

似乎 Rust 假设你已经有一个 C 编译器。 对于 Fedora:

sudo dnf install gcc

如果上述不起作用: cc 包含在"GCC"包中。您需要卸载 GCC,然后在意外替换或删除 cc 二进制文件时重新安装它。

最新更新