Fix the “no acceptable C compiler found in $PATH” error in Ubuntu by installing the required tools and configuring your system properly with this step-by-step guide.
If you’ve encountered the error message below while working with a Linux Ubuntu virtual machine (VM), you’re not alone. This error is commonly seen when trying to run ./configure for compiling software from source:
configure: error: no acceptable C compiler found in $PATH
This message indicates that your system cannot find a C compiler in your system’s $PATH environment variable, which is necessary for compiling software. In this blog post, we will go through a detailed guide to resolve this issue.
What is Causing the Error?
When you attempt to compile software from source using the ./configure command, it tries to verify whether your system has all the necessary tools installed, including a C compiler (like gcc). The error you’re seeing happens because:
- No C compiler is installed on your system.
- The C compiler is installed, but it’s not included in your system’s
$PATH.
Steps to Resolve the Error
Step 1: Verify the Existence of a C Compiler
Before installing any packages, let’s first check if you have a C compiler already installed.
- Open a terminal in your Ubuntu VM.
- Run the following command to check if
gcc(GNU Compiler Collection) is installed:
gcc --version
- If you see the version information of
gcc, it means thatgccis installed but the problem lies elsewhere (probably in your$PATHsettings). - If you see an error like
command not found, this means thatgccis not installed, and you’ll need to install it.
Step 2: Install a C Compiler
Most likely, the issue is that you do not have a C compiler installed. To install gcc, follow these steps:
- Update the Package List First, update the package list to ensure your package manager has the latest information:
sudo apt update
- Install the Build-Essential Package The easiest way to get the
gcccompiler along with other development tools is by installing thebuild-essentialpackage. This package includesgcc,g++,make, and other essential development tools. Run the following command to installbuild-essential:
sudo apt install build-essential
- Verify Installation After the installation is complete, check that
gcchas been installed correctly:
gcc --version
This should display the installed version of the GNU C Compiler.
Step 3: Ensure GCC is in Your PATH
If gcc is installed but you’re still getting the error, it could be that your system’s $PATH is misconfigured and doesn’t include the directory where gcc is located.
- Check Your PATH Variable To view the current directories listed in your
$PATH, run:
echo $PATH
This will display a colon-separated list of directories. You should see something like /usr/bin or /usr/local/bin in that list, which is where gcc is usually installed.
- Add GCC to PATH (If Missing) If
gccis installed in a directory that isn’t in the$PATH, you can add it temporarily or permanently:
- Temporary Solution: Run the following command to add
gccto your current session’s$PATH:export PATH=$PATH:/usr/bin - Permanent Solution: To make this change permanent, open your shell configuration file (
~/.bashrc,~/.zshrc, etc.) in a text editor and add the following line at the end:export PATH=$PATH:/usr/binAfter editing the file, run:source ~/.bashrcThis reloads the file, making the changes effective immediately.
Step 4: Re-Run the Configuration
After installing the necessary tools and ensuring that gcc is properly configured, you can re-run the ./configure command to see if the issue is resolved.
./configure
If everything is set up correctly, you should no longer see the error message, and the configuration should proceed as expected.
Conclusion
The “no acceptable C compiler found in $PATH” error in Linux is quite common when trying to compile software from source. Fortunately, the fix is straightforward—installing the build-essential package usually resolves the issue. If you encounter this error again, simply follow these steps to ensure that a C compiler is installed and available in your $PATH.
By installing build-essential, you also ensure that other critical build tools are set up correctly, which can prevent similar errors in the future.
Now that you’ve resolved the issue, you can continue compiling and installing software smoothly in your Ubuntu VM!


Leave a Reply