If you’ve ever tried to build software from source or compiled a program on a Linux-based system, you’ve probably encountered the infamous error message:
configure: error: no acceptable C compiler found in $PATH
This error occurs during the configuration step when you attempt to build or install a program from source code. It is frustrating, especially when you’re trying to get a program up and running quickly. However, this issue is common and can be resolved with a few simple steps. In this guide, we’ll explain what causes this error and provide a step-by-step approach to fix it.
Understanding the Error
Before diving into the solution, it’s important to understand what this error message means.
The “configure” script is a common part of many open-source software packages. It checks your system for various dependencies and settings before it proceeds with the actual compilation and installation of software. One of the checks the script performs is to verify if the system has a working C compiler available.
In most cases, the error:
configure: error: no acceptable C compiler found in $PATH
indicates that your system is unable to locate a C compiler in the directories listed in your system’s $PATH
environment variable. The $PATH
variable contains a list of directories where the shell looks for executable files. If the required C compiler, such as gcc
, isn’t found in any of those directories, the “configure” script will fail with the error message mentioned above.
Why Do You Need a C Compiler?
A C compiler is an essential tool for software development. It is responsible for converting C source code into executable machine code that your system can run. Most open-source software is written in C or C++, so a C compiler is a critical component of your development environment.
When installing software from source, the configure script looks for a C compiler to compile the code. If the compiler is missing or not installed correctly, the build process cannot proceed, and you’ll encounter the “no acceptable C compiler” error.
Step 1: Verify C Compiler Installation
The first step in resolving this issue is to verify if a C compiler is installed on your system. The most common C compiler on Linux-based systems is GCC (GNU Compiler Collection).
Check if GCC is Installed
Open your terminal and type the following command to check if gcc
is installed:
gcc --version
If the C compiler is installed, you should see output similar to:
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you see an error like command not found
, it means that gcc
is not installed on your system, and you’ll need to install it.
Step 2: Installing a C Compiler
Depending on your Linux distribution, the installation process for gcc
can vary. Below are the commands for installing gcc
on some of the most popular Linux distributions.
On Ubuntu or Debian-based systems:
sudo apt update
sudo apt install build-essential
The build-essential
package includes GCC and other essential tools like make
, which are often required for compiling software from source.
On Fedora, CentOS, or RHEL-based systems:
sudo dnf install gcc
or for CentOS/RHEL:
sudo yum install gcc
On Arch Linux:
sudo pacman -S base-devel
This command installs a number of essential development tools, including GCC, make
, and other build utilities.
On macOS:
If you’re on macOS, you can install the Xcode Command Line Tools, which include GCC, by running:
xcode-select --install
This will install the necessary tools to get started with development on macOS, including the C compiler.
Step 3: Check the $PATH Environment Variable
After installing GCC, you need to ensure that it’s included in your $PATH
. The $PATH
environment variable defines the directories where your system searches for executables.
To check your current $PATH
, run:
echo $PATH
The output will be a colon-separated list of directories where executables are located. For example:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
If GCC is installed, but not in one of the directories listed in your $PATH
, you may need to add it manually.
Add GCC to Your $PATH
If GCC is installed but not found in your $PATH
, you can add the directory containing gcc
to your $PATH
by modifying your shell configuration file.
For bash users, open the .bashrc
or .bash_profile
file:
nano ~/.bashrc
For zsh users, open .zshrc
:
nano ~/.zshrc
Add the following line at the end of the file (replace /path/to/gcc
with the actual path):
export PATH=$PATH:/path/to/gcc
After making the change, save the file and reload the shell configuration:
source ~/.bashrc
or for zsh:
source ~/.zshrc
Now, when you run gcc --version
, it should be correctly located by your system.
Step 4: Ensure All Build Dependencies are Installed
In some cases, the “configure” script may fail due to missing dependencies required by the software you’re trying to compile. The build-essential
package (for Ubuntu/Debian-based systems) usually installs most of the necessary tools, but it’s a good idea to ensure that all dependencies are installed.
For example, if you are trying to compile software that requires libraries or development headers, make sure those are installed as well.
To install commonly needed development tools and libraries on Ubuntu/Debian-based systems:
sudo apt install build-essential libssl-dev libffi-dev zlib1g-dev
For Fedora:
sudo dnf install gcc-c++ make libssl-devel
Step 5: Check for Broken or Missing Symlinks
Sometimes the problem may be caused by broken or missing symbolic links. For example, if there’s a symlink pointing to an old version of GCC or if it was removed, the configure script may fail.
You can verify if the symlink is pointing to the correct version of GCC using:
ls -l /usr/bin/gcc
This command will show you where the symlink is pointing. If it’s broken, you may need to remove the broken link and create a new one pointing to the correct GCC version.
Step 6: Re-run the Configuration Script
Once you’ve installed GCC and ensured it’s in your $PATH
, try re-running the configure
script. This should now work without the error:
./configure
The configure script should detect the C compiler and proceed to the next steps in the installation process.
Conclusion
The error “configure: error: no acceptable C compiler found in $PATH” is usually caused by the absence of a C compiler, such as GCC, or misconfiguration in your system’s $PATH
. By following the steps outlined in this guide, you should be able to resolve this issue and successfully compile and install software from source.
Always remember to ensure that your development tools are up to date, and verify that all necessary dependencies are installed before trying to build or compile software. By doing so, you’ll avoid common build issues and streamline the installation process.
If you’re still encountering issues, double-check your system’s environment, and make sure all dependencies and compilers are properly installed. Happy coding!
Arthur D. Pope is a seasoned expert in diagnosing, analyzing, and resolving all types of errors. With extensive experience in troubleshooting across various industries, Arthur leverages his expertise to assist both individuals and businesses in overcoming challenges. Through his blog, snaptroid.us, he offers insightful guidance on resolving errors and turning setbacks into valuable learning experiences.