Fix: c compiler cannot create executables

In Linux, GCC is the toolchain (set of tools) that links different libraries, changes the code in assembly, and makes executable files. It is a well-known compiler for C programs. While compiling c programs in Linux, terminal users may face the error “c compiler cannot create executables”.

This post will demonstrate the reasons and solutions for the given error. The content for this write-up is as follows:

Reason: Missing Library

The reason for the error “c compiler cannot make executables” is the missing library which can be installed. These utility store headers, soft links (symbolic), and object files necessary to run the c programs. The solution for this error is given below:

Solution 1: Installing Build-Essential

The first solution you can apply is the installation of build-essentials. Build Essential Packages are meta-packages that are used while compiling the programs such as c or c++. This will install the necessary libraries in your operating system that is causing this problem.

You can install the build-essentials packages using the below commands:

For Debian/Ubuntu:

$ sudo apt install build-essential

For Fedora-Based Distributions:

$ dnf group info "C Development Tools and Libraries"

After installing the build-essential packages, run the compiler and check if the problem is resolved or not.

Solution 2: Re-Install GCC

If the above solution is not working or the installed version of GCC is broken, you can try to remove and reinstall it. To remove the GCC compiler in Linux, execute the following commands as per your Linux distribution:

For Debian/Ubuntu:

$ sudo apt autoremove gcc

To install the GCC compiler in Linux operating systems run the following command:

For Fedora/Red hat/RHEL/CentOS:

$ sudo dnf autoremove gcc

For Debian/Ubuntu:

$ sudo apt install gcc

For Fedora/RHEL/CentOS:

$ sudo yum install gcc

Once you are done with the solutions, you can now use GCC to compile and execute C code in Linux.

Note: To get hands-on using GCC, check out our article on GCC.


The reason for this error is the missing library for GCC. To fix this error, there are two possible solutions. The first solution is to install the build-essential packages, which will install all the required libraries for the GCC compiler. The second solution is to remove the GCC compiler and reinstall it using the given commands. This post has demonstrated all the possible reasons and solutions for the given error.