How to fix Rust error “ linker ‘cc’ not found ” on Linux

Today I was testing a network bandwidth utilization tool called Bandwhich On my Ubuntu VM. The tool is Rust programming languageAnd so I tried to install using it cargo Package manager. The following error occurred during the compilation process:

Updating index
Installing bandwhich v0.6.0
Compiling libc v0.2.66
error: linker `cc` not found
= note: No such file or directory (os error 2)

error: aborting due to previous error

error: failed to compile `bandwhich v0.6.0`, intermediate artifacts can be found at `/tmp/cargo-installrqSeTB`

Caused by:
could not compile `libc`.

To learn more, run the command again with --verbose.

As you can see in the output above, Cargo could not find a cc compiler program to compile the specified application. Since Rust does not yet include its own linker, you need a C compiler such as: gcc Installed to function as a linker.

To install gcc on Ubuntu, simply run:

$ sudo apt install build-essential

If you are using another Linux OS, please refer to the following link to install the development tools, including the required applications such as GNU GCC C / C ++ compiler, make, debugger, etc.

  • How to install development tools on Linux

After installing gcc, the “linker` cc` not found “error is gone! And you can install the application without any problems.

If you still get the same error even though GCC is already installed, please install Shimake And try more. Cmake is available in the official repositories of most Linux distributions.

Enable to install Cmake on Arch Linux [Extra] Repository and execution:

$ sudo pacman -S cmake

For Debian, Ubuntu, Linux Mint:

$ sudo apt install cmake

For Fedora:

$ sudo dnf install cmake

For CentOS and RHEL:

$ sudo yum install cmake

For openSUSE:

$ sudo zypper install cmake

For me, installing gcc solved the problem.

Good luck!