Qadry
unixcop Admin

How To Fix Rust “linker ‘cc’ not found” Error On Linux

Introduction

Hello ,

Today I was testing a Rust programming language on my CentOS VM. so I tried to install it and use it with correctly installation in the installation guide article.

When i tried to excute a rust file called unixcop.rs with command rustc , i got this error:

[root@unixcop test]# rustc unixcop.rs 
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

Solution

As you can see in the above output, Cargo couldn’t find cc compiler program to compile the given application. Since Rust does not include its own linker yet, you need to have a C compiler like gcc installed to act as the linker.

To install gcc on CentOS , simply run:

# yum groupinstall "Development Tools"

On Ubuntu:

$ sudo apt install build-essential

After installing gcc, the error “linker cc not found” is gone! And then I can be able to install the application without any issues.

If you still get the same error even GCC is already installed, install cmake and try again. Cmake is available in the official repositories of most Linux distributions.

CentOS,RHEL

$ sudo yum install cmake

Debian,Ubuntu

$ sudo apt install cmake

to get confirm and be sure that everything is OK.. Install gcc and make

# yum install gcc make -y

Installing gcc and make solved the problem for me.

Thank you

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x