In this tutorial, we will look at how to fix the error in C language, Configure error: no acceptable C compiler found in $PATH. When you see the error mentioned here, it basically indicates that a C compiler is not present or not properly configured in your system. We will look at the possible solutions to fix the error in upcoming section.
What is “Configure error: no acceptable C compiler found in $PATH” error?
As we know, software applications which are written in C or C++ needs a compiler (like GCC, CLANG or Microsoft Visual C++) to translate the source code into machine executable code. This error indicates that the software’s build/configuration script could not locate any C compiler in the directories listed in $PATH variable in your system. To resolve this issue, We will use 3 possible solutions mentioned in the next section.
[SOLVED]: Configure error: no acceptable C compiler found in $PATH
- Any user with sudo privilege/root user privilege required
- Basic understanding of Linux CLI commands
Solution-1: Install “C” Compiler
In this step, check if C compiler is installed in your machine using any of the below commands. If you get the output as shown below, that means C compiler is not installed in your machine.
[root@linuxnasa ~]# gcc -v -bash: gcc: command not found [root@linuxnasa ~]# which gcc /usr/bin/which: no gcc in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/go/bin:/root/bin) [root@linuxnasa ~]# rpm -qa | grep gcc
Next, install the C compiler using below command.
To install gcc on Ubuntu
[root@linuxnasa ~]# apt-get install -y gcc [root@linuxnasa ~]# apt-get install build-essential
To install gcc on RHEL/CentOS 7
[root@linuxnasa ~]# yum install -y gcc [root@linuxnasa ~]# yum groupinstall "Development tools"
To install on CentOS 8/Rocky Linux
[root@linuxnasa ~]# dnf install -y gcc [root@linuxnasa ~]# dnf groupinfo "Development Tools"
Solution-2: Configure $PATH Variable
In this step, check if gcc compiler is configured in PATH variable using below command.
[root@linuxnasa ~]# echo $PATH
Next, if you do not see the gcc compiler path added. Add the gcc compiler path using below command.
[root@linuxnasa ~]# export PATH=$PATH:<path-to-gcc-compiler>
Solution-3: Check Corrupted “C” Compiler
In this step, make sure you have provided the necessary permissions to the C compiler which you have installed. Also, make sure C compiler is correctly installed and configured in your machine. You can uninstall the C compiler and reinstall using Step-1 of this this tutorial.