In this article, we will see how to solve "Configure error: no acceptable C compiler found in $PATH"
which you might encounter while trying to install an application through source code. It is not very uncommon for users to get this error. It may occur during installation due to many reasons. Something like this happened to me as well when I was trying to install snort application on my Ubuntu system.
The installation failed at the configuration step with "Configure error: no acceptable C compiler found in $PATH"
while trying to run configure
script. After checking the error for a while, I understood the root cause of the problem and then decided to write an article about this so that it will help you folks as well. Here we will see all the possible solution that you can apply to solve "Configure
.
[Solved]: “Configure error: no acceptable C compiler found in $PATH”
Also Read: How to Install Caddy Web Server on Linux: [6 Easy Steps]
As I was explaining, while trying to run configure
script during installation of snort application, I noticed configure: error: no acceptable C compiler found in $PATH
on the output as you can see below.
cyberithub@ubuntu:~/snort-2.9.20$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports the include directive... yes (GNU style) checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/home/cyberithub/snort-2.9.20': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
While the reason for above error could vary from system to system depending on your current scenario but it is often observed, this configure: error: no acceptable C compiler found in $PATH
occurs mainly due to compiler package missing in your system or if installed then it is on customized path which is currently not visible to the system. In rare cases, it also occurs due to corrupt installation or due to missing dependency packages. Here we will go through all the possible solutions that you can take to solve configure: error: no acceptable C compiler found in $PATH
.
Solution 1: Install gcc compiler
The most common cause for configure: error: no acceptable C compiler found in $PATH error is the missing gcc compiler in the system. So to fix the error you just have to install the compiler by using sudo apt install gcc
command on Ubuntu/Debian based systems and sudo yum install gcc
or sudo dnf install gcc
on RHEL/CentOS based systems.
cyberithub@ubuntu:~$ sudo apt install gcc Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: gcc-multilib gcc-doc The following NEW packages will be installed: gcc 0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded. Need to get 5,208 B of archives. After this operation, 51.2 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 gcc amd64 4:9.3.0-1ubuntu2 [5,208 B] Fetched 5,208 B in 0s (15.8 kB/s) Selecting previously unselected package gcc. (Reading database ... 258097 files and directories currently installed.) Preparing to unpack .../gcc_4%3a9.3.0-1ubuntu2_amd64.deb ... Unpacking gcc (4:9.3.0-1ubuntu2) ... Setting up gcc (4:9.3.0-1ubuntu2) ... Processing triggers for man-db (2.9.1-1) ...
Solution 2: Set $PATH
Sometimes you might see gcc compiler installed but since the path is currently not visible to the system, you will still get configure: error: no acceptable C compiler found in $PATH
. So to deal with this problem, you simply have to set the compiler path to $PATH
global environment variable using below export
command.
export PATH=$PATH:/gcc/compiler/path
However to make the changes permanent, you have to add an entry in either ~/.bashrc
or ~/.profile
file and then log out and login back to refresh the changes.
Solution 3: Install build-essential/development tools
You can also use an alternate solution to solve configure: error: no acceptable C compiler found in $PATH
on Ubuntu/Debian based system where instead of installing just gcc
package, you can install build-essential
package which contains bundles of packages including gcc
. You just have to run sudo apt install build-essential
command as shown below. This will download and install the package along with all its dependencies.
cyberithub@ubuntu:~$ sudo apt install build-essential Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: g++ g++-9 gcc libstdc++-9-dev Suggested packages: g++-multilib g++-9-multilib gcc-9-doc gcc-multilib gcc-doc libstdc++-9-doc The following NEW packages will be installed: build-essential g++ g++-9 gcc libstdc++-9-dev 0 upgraded, 5 newly installed, 0 to remove and 57 not upgraded. Need to get 10.2 MB of archives. After this operation, 46.8 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 gcc amd64 4:9.3.0-1ubuntu2 [5,208 B] Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 libstdc++-9-dev amd64 9.4.0-1ubuntu1~20.04.2 [1,722 kB] Get:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 g++-9 amd64 9.4.0-1ubuntu1~20.04.2 [8,421 kB] Get:4 http://in.archive.ubuntu.com/ubuntu focal/main amd64 g++ amd64 4:9.3.0-1ubuntu2 [1,604 B] Get:5 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 build-essential amd64 12.8ubuntu1.1 [4,664 B] Fetched 10.2 MB in 6s (1,823 kB/s) Selecting previously unselected package gcc. (Reading database ... 258097 files and directories currently installed.) Preparing to unpack .../gcc_4%3a9.3.0-1ubuntu2_amd64.deb ... ..............................................................
Similarly, if you are using RHEL/CentOS based systems then instead of installing gcc, you can install bundle of packages which includes gcc as well using sudo yum groupinstall "Development Tools"
command as shown below.
[cyberithub@centos7 ~]$ sudo yum groupinstall "Development Tools" Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: epel.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Resolving Dependencies --> Running transaction check ---> Package autoconf.noarch 0:2.69-11.el7 will be installed --> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch ---> Package automake.noarch 0:1.13.4-3.el7 will be installed --> Processing Dependency: perl(Thread::Queue) for package: automake-1.13.4-3.el7.noarch --> Processing Dependency: perl(TAP::Parser) for package: automake-1.13.4-3.el7.noarch ---> Package bison.x86_64 0:3.0.4-2.el7 will be installed ---> Package byacc.x86_64 0:1.9.20130304-3.el7 will be installed ---> Package cscope.x86_64 0:15.8-10.el7 will be installed ---> Package ctags.x86_64 0:5.8-13.el7 will be installed ---> Package diffstat.x86_64 0:1.57-4.el7 will be installed .....................................................
If you are using OpenSUSE based systems then you can run sudo zypper install --type pattern devel_basis
command as shown below.
sudo zypper install --type pattern devel_basis
If you are having alpine based systems then run sudo apk add build-base
command as shown below.
sudo apk add build-base
Solution 4: Reinstall gcc compiler
In few of the rare cases, it is possible that installed gcc compiler is not working due to some missing files or due to some other reasons. Most probably it got corrupted and now it does not work anymore. So in that case, you may have to remove all the files manually as uninstallation command might not work properly. After doing the clean up, you have to try installing it again and see if it works. This step requires lot of manual effort and expertise but this might be the only way to fix the error.
After following above solution, I am sure you will be able to solve your error as well. To me, Solution 1
worked perfectly where I just had to install gcc
compiler. After that when I ran configure
script again, it is now able to detect the compiler and proceed with the installation steps as you can see below.
cyberithub@ubuntu:~/snort-2.9.20$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports the include directive... yes (GNU style) checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables...
Discover more from Ubuntu-Server.com
Subscribe to get the latest posts sent to your email.