How do I fix the Rust error "linker 'cc' not found" for Debian on Windows 10?

LinuxWindowsRust

Linux Problem Overview


I'm running Debian on Windows 10 (Windows Subsystem for Linux) and installed Rust using the command:

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

There were no errors in the install, but when I tried to compile with rustc I got the error linker 'cc' not found.

Linux Solutions


Solution 1 - Linux

The Linux Rust installer doesn't check for a compiler toolchain, but seems to assume that you've already got a C linker installed! The best solution is to install the tried-and-true gcc toolchain.

sudo apt install build-essential

If you need to target another architecture, install the appropriate toolchain and target the compilation as follows:

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

Solution 2 - Linux

I ran the following 2 commands and it worked.

sudo apt-get update
sudo apt install build-essential

Solution 3 - Linux

Solution for CentOS:

yum -y install gcc

Solution 4 - Linux

You have to install some dependencies

for Arch Linux sudo pacman -S base-devel

for Ubuntu sudo apt install build-essential

for Centos sudo yum install gcc

Solution 5 - Linux

Solution for Solus:

sudo eopkg it -c system.devel

Solution 6 - Linux

Please do an "Update and Upgrade" before installing setup tools.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionThane PlummerView Question on Stackoverflow
Solution 1 - LinuxThane PlummerView Answer on Stackoverflow
Solution 2 - LinuxRahul SoshteView Answer on Stackoverflow
Solution 3 - LinuxEvgeny LebedevView Answer on Stackoverflow
Solution 4 - LinuxnaimjeemView Answer on Stackoverflow
Solution 5 - LinuxAdam LesniakView Answer on Stackoverflow
Solution 6 - LinuxSyenixView Answer on Stackoverflow