How to Fix the “no acceptable C compiler found in $PATH” Error in Linux Ubuntu VM

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:

  1. No C compiler is installed on your system.
  2. 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.

  1. Open a terminal in your Ubuntu VM.
  2. 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 that gcc is installed but the problem lies elsewhere (probably in your $PATH settings).
  • If you see an error like command not found, this means that gcc is 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:

  1. Update the Package List First, update the package list to ensure your package manager has the latest information:
   sudo apt update
  1. Install the Build-Essential Package The easiest way to get the gcc compiler along with other development tools is by installing the build-essential package. This package includes gcc, g++, make, and other essential development tools. Run the following command to install build-essential:
   sudo apt install build-essential
  1. Verify Installation After the installation is complete, check that gcc has 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.

  1. 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.

  1. Add GCC to PATH (If Missing) If gcc is 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 gcc to 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/bin After editing the file, run: source ~/.bashrc This 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

Up ↑

Discover more from JD Bots

Subscribe now to keep reading and get access to the full archive.

Continue reading