How to Solve Source Compile Error configure: error: no acceptable C compiler found in $PATH in Linux Ubuntu

Posted on

Description on The Error Triggered upon Compilation Process

This is an article similar with the previous article titled ‘How to Solve Source Compile Error configure: error: no acceptable C compiler found in $PATH in Linux CentOS’. The article exist in this link. The main problem is actually the same, it is the problem in the process of compiling source. There is a specific error similar with the other article in this link where it is also the title of this article. As shown in the similar article, the error given for an example actually exists in the process of compiling a PostgreSQL Database Server’s source. The output showing the error message is available below  :

root@hostname:/home/user/Downloads/postgresql-10.5# ./configure --prefix=/opt/postgresql-10.5/app
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... no
checking for cc... no
configure: error: in `/home/user/Downloads/postgresql-10.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
root@hostname:/home/user/Downloads/postgresql-10.5#

So, there is no  acceptable C compiler found in $PATH as the error message in the above output shows. As a result, the continuation compilation process of PostgreSQL Database Server is not possible. The above error have a proper solution which is similar with the other article in this link. It is by installing a specific package or tool in Linux Ubuntu operating system distribution. Generally, in any Linux operating sytem distribution, the package or tool responsible for the compilation task is ‘gcc’.  Before moving forward, the following is the information about the suitable package or tool available in Ubuntu for compiling process by executing the command ‘apt show gcc’ :

root@hostname:~# apt show gcc
Package: gcc
Version: 4:7.3.0-3ubuntu2.1
Priority: optional
Build-Essential: yes
Section: devel
Source: gcc-defaults (1.176ubuntu2.1)
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 51,2 kB
Provides: c-compiler
Depends: cpp (>= 4:7.3.0-3ubuntu2.1), gcc-7 (>= 7.3.0-27~)
Recommends: libc6-dev | libc-dev
Suggests: gcc-multilib, make, manpages-dev, autoconf, automake, libtool, flex, bison, gdb, gcc-doc
Conflicts: gcc-doc (<< 1:2.95.3)
Supported: 5y
Download-Size: 5.184 B
APT-Manual-Installed: no
APT-Sources: http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
Description: GNU C compiler
This is the GNU C compiler, a fairly portable optimizing compiler for C.
.
This is a dependency package providing the default GNU C compiler.

N: There is 1 additional record. Please use the '-a' switch to see it
root@hostname:~#

 

Steps taken to Solve Error Compilation Problem in Ubuntu 18.04. Looking for the ‘gcc’ tool.

For Ubuntu 18.04 Linux operating system distribution, the steps for installing the requirement package or tools for compiling source files are not totally different with the other Linux operating system distribution. It is shown below :

First step, just search the packages responsible for compiling process. In Ubuntu, there is a tool for managing software, packages or tools. It is the ‘apt’ package tool. In the early years, the specific package, tool representing a command for searching the appropriate package is the ‘apt-cache’ package tool. But nowadays, the ‘apt’ package tool is available for doing the same purpose with the additional argument ‘search’. Below. The following are those commands for searching the compiler package or tool :

The first one is the ‘apt-cache’.

apt-cache search --names-only "^gcc$"

The execution of the command is shown below :

root@hostname:~# apt-cache search "^gcc$"
gcc - GNU C compiler
root@hostname:~#

The output shows the name of the package and also a short information about the package. The above command has a regular expression pattern specifying on the searching pattern. The pattern is to search an exact package or tool named ‘gcc’. Using the ‘apt’ package or tool can also achieve the above searching task process as follows  :

apt search --names-only "^gcc$"
root@hostname:~# apt search --names-only "^gcc$"
Sorting... Done
Full Text Search... Done
gcc/bionic-updates,now 4:7.3.0-3ubuntu2.1 amd64 [installed,automatic]
GNU C compiler

root@hostname:~#

Furthermore, check if the package or tool is available and it is ready to use. How to check an installed package or tool in the Ubuntu Linux operating system ?. Below is the actual command to check if the package or tool with the name of ‘gcc’ is already exist :

apt list --installed | grep gcc

The output of the command execution is shown below :

root@hostname:~# apt list --installed | grep gcc

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

root@hostname:~#

 

Steps taken to Solve Error Compilation Problem in Ubuntu 18.04. An alternative package or tool named ‘build-essential’.

Apparently, based on the above output command execution, the package or tool named ‘gcc’ is not installed yet. But fortunately, in Ubuntu Linux operating system distribution there is another package which is appropriate and it is suitable for the installation process. It is the ‘build-essential’ package. Before installing ‘build-essential’, below is the detail information about the package. The information is available by executing the command ‘apt show build-essential’ as follows :

root@hostname:~# apt show build-essential
Package: build-essential
Version: 12.4ubuntu1
Priority: optional
Build-Essential: yes
Section: devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 20,5 kB
Depends: libc6-dev | libc-dev, gcc (>= 4:7.2), g++ (>= 4:7.2), make, dpkg-dev (>= 1.17.11)
Supported: 5y
Download-Size: 4.758 B
APT-Manual-Installed: yes
APT-Sources: http://id.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
Description: Informational list of build-essential packages
If you do not plan to build Debian packages, you don't need this
package. Starting with dpkg (>= 1.14.18) this package is required
for building Debian packages.
.
This package contains an informational list of packages which are
considered essential for building Debian packages. This package also
depends on the packages on that list, to make it easy to have the
build-essential packages installed.
.
If you have this package installed, you only need to install whatever
a package specifies as its build-time dependencies to build the
package. Conversely, if you are determining what your package needs
to build-depend on, you can always leave out the packages this
package depends on.
.
This package is NOT the definition of what packages are
build-essential; the real definition is in the Debian Policy Manual.
This package contains merely an informational list, which is all
most people need. However, if this package and the manual disagree,
the manual is correct.

root@hostname:~#

So, how can installing build-essential can also automatically install ‘gcc’ package or tool ?. Below is the information where it is specifically giving the package dependencies information. It means, the success of installing ‘build-essential’ package or tool depends on these lists of package or tools. These lists of package or tools must be exist before the installation of ‘build-essential’ can start. In other words, there is a checking process for the availability of those lists of packages or tools. If those packages or tools are not available, ‘apt’ will install those packages or tools first.  The following is the command execution to provide the dependency packages or tools information :

root@hostname:~# apt-cache depends build-essential
build-essential
 |Depends: libc6-dev
  Depends: 
    libc6-dev
  Depends: gcc
  Depends: g++
  Depends: make
    make-guile
  Depends: dpkg-dev
root@hostname:~#

Based on the output of the command above, it is better to install build-essential because there are lots of useful package or tool aside from ‘gcc’ will be available by only installing ‘build-essential’ package.

First of all, check the availability of package or tool. Below is the command to accomplish the task :

apt-cache search "^build-essential$"

Thus, the output of the above command execution :

root@hostname:~# apt-cache search "^build-essential$"
build-essential - Informational list of build-essential packages
root@hostname:~#

Similarly, another command to accomplish the same task :

apt search "^build-essential$"

Again, the output of the above command execution :

root@hostnamer:~# apt search "^build-essential$"
Sorting... Done
Full Text Search... Done
build-essential/bionic,now 12.4ubuntu1 amd64 [installed]
  Informational list of build-essential packages

root@hostname:~# 

Well, luckily the package exist the check whether the package or tool named ‘build-essential’ has been installed by executing the following command :

The following is the output of the above command execution :

root@localhost:~# apt-cache search --names-only "^gcc$"
gcc - GNU C compiler
root@localhost:~#  
root@localhost:~# apt-cache depends build-essential
build-essential
 |Depends: libc6-dev
  Depends: 
    libc6-dev
  Depends: gcc
  Depends: g++
  Depends: make
    make-guile
  Depends: dpkg-dev
root@localhost:~# 

Solving the error by installing ‘build-essential’ package or tool

Finally, after ensuring the ‘build-essential’ package or tool is available, install it by typing the following command in the command line :

root@localhost:~# apt -y install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libc-dev-bin libc6-dev libcilkrts5 libfakeroot libgcc-7-dev libitm1
  liblsan0 libmpx2 libquadmath0 libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev
Suggested packages:
  debian-keyring g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg gcc-multilib autoconf automake libtool flex bison gcc-doc gcc-7-multilib gcc-7-locales libgcc1-dbg libgomp1-dbg libitm1-dbg
  libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg glibc-doc libstdc++-7-doc make-doc
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libc-dev-bin libc6-dev libcilkrts5 libfakeroot
  libgcc-7-dev libitm1 liblsan0 libmpx2 libquadmath0 libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev make manpages-dev
0 upgraded, 27 newly installed, 0 to remove and 8 not upgraded.
Need to get 26,8 MB of archives.
After this operation, 117 MB of additional disk space will be used.
Get:1 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 libc-dev-bin amd64 2.27-3ubuntu1 [71,8 kB]
Get:2 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-libc-dev amd64 4.15.0-38.41 [1.006 kB]
Get:3 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 libc6-dev amd64 2.27-3ubuntu1 [2.587 kB]                                                                                                       
Get:4 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libitm1 amd64 8.2.0-1ubuntu2~18.04 [28,1 kB]                                                                                           
Get:5 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libatomic1 amd64 8.2.0-1ubuntu2~18.04 [9.064 B]                                                                                        
Get:6 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libasan4 amd64 7.3.0-27ubuntu1~18.04 [358 kB]                                                                                          
Get:7 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 liblsan0 amd64 8.2.0-1ubuntu2~18.04 [132 kB]                                                                                           
Get:8 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libtsan0 amd64 8.2.0-1ubuntu2~18.04 [288 kB]                                                                                           
Get:9 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libubsan0 amd64 7.3.0-27ubuntu1~18.04 [126 kB]                                                                                         
Get:10 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcilkrts5 amd64 7.3.0-27ubuntu1~18.04 [42,5 kB]                                                                                     
Get:11 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmpx2 amd64 8.2.0-1ubuntu2~18.04 [11,7 kB]                                                                                          
Get:12 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libquadmath0 amd64 8.2.0-1ubuntu2~18.04 [133 kB]                                                                                      
Get:13 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgcc-7-dev amd64 7.3.0-27ubuntu1~18.04 [2.380 kB]                                                                                   
Get:14 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc-7 amd64 7.3.0-27ubuntu1~18.04 [7.455 kB]                                                                                          
Get:15 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc amd64 4:7.3.0-3ubuntu2.1 [5.184 B]                                                                                                
Get:16 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libstdc++-7-dev amd64 7.3.0-27ubuntu1~18.04 [1.463 kB]                                                                                
Get:17 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++-7 amd64 7.3.0-27ubuntu1~18.04 [7.570 kB]                                                                                          
Get:18 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++ amd64 4:7.3.0-3ubuntu2.1 [1.572 B]                                                                                                
Get:19 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 make amd64 4.1-9.1ubuntu1 [154 kB]                                                                                                            
Get:20 http://id.archive.ubuntu.com/ubuntu bionic-updates/main amd64 dpkg-dev all 1.19.0.5ubuntu2.1 [608 kB]                                                                                               
Get:21 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 build-essential amd64 12.4ubuntu1 [4.758 B]                                                                                                   
Get:22 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 libfakeroot amd64 1.22-2ubuntu1 [25,9 kB]                                                                                                     
Get:23 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 fakeroot amd64 1.22-2ubuntu1 [62,3 kB]                                                                                                        
Get:24 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47,6 kB]                                                                                                
Get:25 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-diff-xs-perl amd64 0.04-5 [11,1 kB]                                                                                              
Get:26 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-merge-perl all 0.08-3 [12,0 kB]                                                                                                  
Get:27 http://id.archive.ubuntu.com/ubuntu bionic/main amd64 manpages-dev all 4.15-1 [2.217 kB]                                                                                                            
Fetched 26,8 MB in 27s (979 kB/s)                                                                                                                                                                          
Selecting previously unselected package libc-dev-bin.
(Reading database ... 164199 files and directories currently installed.)
Preparing to unpack .../00-libc-dev-bin_2.27-3ubuntu1_amd64.deb ...
Unpacking libc-dev-bin (2.27-3ubuntu1) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../01-linux-libc-dev_4.15.0-38.41_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.15.0-38.41) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../02-libc6-dev_2.27-3ubuntu1_amd64.deb ...
Unpacking libc6-dev:amd64 (2.27-3ubuntu1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../03-libitm1_8.2.0-1ubuntu2~18.04_amd64.deb ...
Unpacking libitm1:amd64 (8.2.0-1ubuntu2~18.04) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../04-libatomic1_8.2.0-1ubuntu2~18.04_amd64.deb ...
Unpacking libatomic1:amd64 (8.2.0-1ubuntu2~18.04) ...
Selecting previously unselected package libasan4:amd64.
Preparing to unpack .../05-libasan4_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking libasan4:amd64 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../06-liblsan0_8.2.0-1ubuntu2~18.04_amd64.deb ...
Unpacking liblsan0:amd64 (8.2.0-1ubuntu2~18.04) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../07-libtsan0_8.2.0-1ubuntu2~18.04_amd64.deb ...
Unpacking libtsan0:amd64 (8.2.0-1ubuntu2~18.04) ...
Selecting previously unselected package libubsan0:amd64.
Preparing to unpack .../08-libubsan0_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking libubsan0:amd64 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package libcilkrts5:amd64.
Preparing to unpack .../09-libcilkrts5_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking libcilkrts5:amd64 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package libmpx2:amd64.
Preparing to unpack .../10-libmpx2_8.2.0-1ubuntu2~18.04_amd64.deb ...
Unpacking libmpx2:amd64 (8.2.0-1ubuntu2~18.04) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../11-libquadmath0_8.2.0-1ubuntu2~18.04_amd64.deb ...
Unpacking libquadmath0:amd64 (8.2.0-1ubuntu2~18.04) ...
Selecting previously unselected package libgcc-7-dev:amd64.
Preparing to unpack .../12-libgcc-7-dev_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking libgcc-7-dev:amd64 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package gcc-7.
Preparing to unpack .../13-gcc-7_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking gcc-7 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package gcc.
Preparing to unpack .../14-gcc_4%3a7.3.0-3ubuntu2.1_amd64.deb ...
Unpacking gcc (4:7.3.0-3ubuntu2.1) ...
Selecting previously unselected package libstdc++-7-dev:amd64.
Preparing to unpack .../15-libstdc++-7-dev_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking libstdc++-7-dev:amd64 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package g++-7.
Preparing to unpack .../16-g++-7_7.3.0-27ubuntu1~18.04_amd64.deb ...
Unpacking g++-7 (7.3.0-27ubuntu1~18.04) ...
Selecting previously unselected package g++.
Preparing to unpack .../17-g++_4%3a7.3.0-3ubuntu2.1_amd64.deb ...
Unpacking g++ (4:7.3.0-3ubuntu2.1) ...
Selecting previously unselected package make.
Preparing to unpack .../18-make_4.1-9.1ubuntu1_amd64.deb ...
Unpacking make (4.1-9.1ubuntu1) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../19-dpkg-dev_1.19.0.5ubuntu2.1_all.deb ...
Unpacking dpkg-dev (1.19.0.5ubuntu2.1) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../20-build-essential_12.4ubuntu1_amd64.deb ...
Unpacking build-essential (12.4ubuntu1) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../21-libfakeroot_1.22-2ubuntu1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.22-2ubuntu1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../22-fakeroot_1.22-2ubuntu1_amd64.deb ...
Unpacking fakeroot (1.22-2ubuntu1) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../23-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../24-libalgorithm-diff-xs-perl_0.04-5_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-5) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../25-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../26-manpages-dev_4.15-1_all.deb ...
Unpacking manpages-dev (4.15-1) ...
Setting up libquadmath0:amd64 (8.2.0-1ubuntu2~18.04) ...
Setting up libatomic1:amd64 (8.2.0-1ubuntu2~18.04) ...
Setting up make (4.1-9.1ubuntu1) ...
Setting up libasan4:amd64 (7.3.0-27ubuntu1~18.04) ...
Setting up libcilkrts5:amd64 (7.3.0-27ubuntu1~18.04) ...
Setting up libubsan0:amd64 (7.3.0-27ubuntu1~18.04) ...
Setting up libtsan0:amd64 (8.2.0-1ubuntu2~18.04) ...
Setting up linux-libc-dev:amd64 (4.15.0-38.41) ...
Setting up liblsan0:amd64 (8.2.0-1ubuntu2~18.04) ...
Setting up libmpx2:amd64 (8.2.0-1ubuntu2~18.04) ...
Setting up dpkg-dev (1.19.0.5ubuntu2.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libfakeroot:amd64 (1.22-2ubuntu1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libc-dev-bin (2.27-3ubuntu1) ...
Setting up manpages-dev (4.15-1) ...
Setting up libc6-dev:amd64 (2.27-3ubuntu1) ...
Setting up libitm1:amd64 (8.2.0-1ubuntu2~18.04) ...
Setting up fakeroot (1.22-2ubuntu1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libgcc-7-dev:amd64 (7.3.0-27ubuntu1~18.04) ...
Setting up libstdc++-7-dev:amd64 (7.3.0-27ubuntu1~18.04) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-5) ...
Setting up gcc-7 (7.3.0-27ubuntu1~18.04) ...
Setting up g++-7 (7.3.0-27ubuntu1~18.04) ...
Setting up gcc (4:7.3.0-3ubuntu2.1) ...
Setting up g++ (4:7.3.0-3ubuntu2.1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
root@localhost:~# 

As shown in the above output, the installation process of ‘build-essential’ ends successfully. It means the ‘gcc’ tool is available. So, try to execute the compile command again.

Leave a Reply