How to Fix Rust Error Linker CC Not Found on Linux

Did you just encounter a “Linker ‘cc’ not found” error while installing your favourite Rust program from Cargo Package Manager if yes then let me show you how to fix it up.

Don’t worry, the same situation happened to me just now while installing my favourite tool tere and I have resolved it with a few commands that I’m about to share with you.

The steps are simple; you just need to install a few utilities that will solve this error.

How to Fix Rust Error “linker ‘cc’ not found” on Linux

First, let me tell you the reason for this error.

While installing any application wrapped in the Rust programming language requires compilation tools like the CC compiler.

Most of the time, this tool is present in your system or gets installed with the Rust & Cargo installation. However, in some rare situations, if the compiler is missing, then you will get the following error.

  Downloaded log v0.4.17
  Downloaded serde_json v1.0.85
  Downloaded aho-corasick v0.7.18
  Downloaded terminal_size v0.1.17
  Downloaded cfg-if v1.0.0
  Downloaded 38 crates (2.8 MB) in 1.03s
   Compiling libc v0.2.132
   Compiling memchr v2.5.0
   Compiling autocfg v1.1.0
   Compiling cfg-if v1.0.0
   Compiling log v0.4.17
error: linker `cc` not found
  = note: No such file or directory (os error 2)

error: could not compile `log` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `tere v1.1.0`, intermediate artifacts can be found at `/tmp/cargo-installYmjmW8`

Caused by:
  build failed

As you look above, at the end of the line you will find the phrase “Caused by: build failed“. It simply means that while installing the tere Rust package from the Cargo package manager, it was unable to find any relevant linker to compile the program like the CC compiler.

To solve this error, you just need to install the development tools on your system, which will include the necessary tools like the GNU GCC C/C+ compiler, make, debugger, etc.

How to Install Development Tools on Linux

Follow one of the following methods to install the development tools package on your system:

On Ubuntu or Debian-based distributions, users can install it using the following command from their APT package manager.

$ sudo apt update
$ sudo apt install build-essential

For RHEL, Fedora, or using their derivatives, users can install it using the DNF package manager by issuing the following command.

$ sudo dnf update
$ sudo dnf groupinstall "Development Tools"

Users of Arch or Manjaro can install it from their default Pacman package manager.

$ sudo pacman -Syyu
$ sudo pacman -Sy base-devel

After installing the development tools, the error “linker ‘cc’ not found” will disappear. However, if the error still persists, then try to install CMake and GCC by using the following methods.

Installing GCC & CMake Programs on Linux

Choose one of the following methods that are relevant to your current distribution:

For Ubuntu or Debian-based distributions, users can install it with the following command.

$ sudo apt install gcc cmake

On Arch or Manjaro, users can use the following command.

$ sudo pacman -Sy gcc cmake

Lastly, RHEL or Fedora users can install it with the following command.

$ sudo dnf install gcc cmake

That’s all you require to avoid the error. If you are still getting the same error repeatedly even after following all of the above-mentioned methods, then do let us know in the comment section.

Leave a Reply