215

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.

Boiethios
  • 38,438
  • 19
  • 134
  • 183
Thane Plummer
  • 7,966
  • 3
  • 26
  • 30

11 Answers11

335

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
Boiethios
  • 38,438
  • 19
  • 134
  • 183
Thane Plummer
  • 7,966
  • 3
  • 26
  • 30
57

I ran the following 2 commands and it worked.

sudo apt-get update
sudo apt install build-essential
Rahul Soshte
  • 798
  • 8
  • 11
50

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

for Solus: sudo eopkg it -c system.devel

LeoDog896
  • 3,472
  • 1
  • 15
  • 40
naimjeem
  • 657
  • 6
  • 7
25

Solution for CentOS:

yum -y install gcc
Eugene Lebedev
  • 1,400
  • 1
  • 18
  • 30
12

if u are on wsl2 - ubuntu try to update the pacakges with following cmds:

sudo apt-get update
sudo apt install build-essential
The_Third_Eye
  • 303
  • 3
  • 15
7

I ran the following commands in wsl1, it worked

sudo apt-get update
sudo apt install build-essential
grudev
  • 485
  • 1
  • 6
  • 15
2

Solution for Solus:

sudo eopkg it -c system.devel
Adam Lesniak
  • 878
  • 10
  • 32
1

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

Syenix
  • 208
  • 2
  • 9
1

You can fix this problem by adding build essential package in linux

sudo apt install -y build-essential

Mansur Ul Hasan
  • 2,898
  • 27
  • 24
arora
  • 11
  • 2
1

It seems Rust assumes you already have a C compiler. For Fedora:

sudo dnf install gcc

0

IF ABOVE IS NOT WORKING: cc is included in the "GCC" package. You need to uninstall GCC and then reinstall it if you have accidentally replaced or removed the cc binary.

Poseidon
  • 165
  • 1
  • 8