Fix error: no acceptable C compiler found in $PATH

Written By: Nathan Kellert

Posted On:

Fix error no acceptable C compiler found in $PATH

Learn how to fix the no acceptable C compiler found in $PATH error in Linux, macOS, and Windows with my easy guide solutions.

If you’ve ever tried to install software or compile code on a Linux or Unix-based system (like macOS), you might have run into the error:

This error typically happens when you try to build a program from source code and the system can’t find a C compiler to compile the code. But don’t worry – it’s an easy fix! Let’s walk through what this means and how you can solve it, step by step.

Why It Occurs?

When you try to install software from source (i.e., from code files) so many programs use a configure script to prepare the environment for building the software.

The script checks if all the tools you need are available, including a C compiler (like gcc or clang).

This error message is saying that the system couldn’t find a C compiler in the list of directories it looks in for executable programs.

Essentially, it doesn’t know where to find gcc or any other C compiler.

How to Fix It

Here’s how you can easily fix this issue depending on your operating system:

1. Check If a C Compiler is Installed

First, let’s check if you already have a C compiler installed (like gcc or clang). Open a terminal and type:

gcc --version

Or:

clang --version

If the system responds with the version number of gcc or clang, then you already have a compiler installed. If it says something like command not found, then you don’t have a compiler installed, and we need to install one.

2. Installing a C Compiler

If you don’t have a compiler installed, here’s how to install one based on your operating system:

On Ubuntu/Debian (or other Debian-based systems):

  1. Open your terminal.
  2. Install the build-essential package, which includes the gcc compiler and other necessary development tools: sudo apt update sudo apt install build-essential This will install gcc, g++, and other tools needed for compiling C programs.

On Fedora/CentOS (or other Red Hat-based systems):

  1. Open your terminal.
  2. Install the development tools package: sudo dnf groupinstall "Development Tools" This will install gcc and related tools.

On macOS:

  1. Open your terminal.
  2. You can install the Xcode Command Line Tools (which includes clang, the C compiler) by typing: xcode-select --install This command will prompt you to install the tools. Just follow the instructions to complete the installation.

On Windows:

Windows doesn’t come with a C compiler preinstalled like Linux and macOS, so you’ll need to install one manually. The easiest way to get started is by installing MinGW (Minimalist GNU for Windows) or using the Windows Subsystem for Linux (WSL).

Here’s how to do it with MinGW:

  1. Download and install MinGW from MinGW website.
  2. After installing, make sure the path to the bin directory (where gcc.exe is located) is added to your system’s PATH.

3. Add the Compiler to Your $PATH

If you’ve installed the compiler but still see the error, it might be because the system doesn’t know where to find it. This usually means the directory containing the compiler isn’t included in the $PATH environment variable.

Here’s how to fix that:

  1. Find the path to the compiler. For example, if you installed gcc on Ubuntu, it’s usually located in /usr/bin/gcc.
  2. Add the path to $PATH:
    • On Linux/macOS, you can add this to your ~/.bashrc or ~/.bash_profile (for bash users) or ~/.zshrc (for zsh users).
    • Open the file in a text editor: nano ~/.bashrc # or ~/.bash_profile, ~/.zshrc
    • Add the following line at the end of the file (replace /usr/bin with the actual path to your compiler): export PATH=$PATH:/usr/bin
    • Save the file and run: source ~/.bashrc # or the file you edited
    This will update your $PATH and allow the system to find your compiler.

4. Verify the Compiler Is Working

Once you’ve installed the compiler and made sure it’s on the $PATH, try running the gcc --version or clang --version command again. You should see something like:

gcc (GCC) 9.3.0

This confirms that your C compiler is installed and ready to use.

5. Run the Configure Script Again

Now that you have a C compiler installed and properly configured, try running the configure script again:

./configure

It should work without the “no acceptable C compiler” error this time.

Conclusion

The error “configure: error: no acceptable C compiler found in $PATH” usually means that your system doesn’t have a C compiler installed, or it’s not correctly set up. By following the steps above, you can easily install and configure a C compiler, and the error should disappear.

Key Steps to Fix the Error:

  1. Check if you have a C compiler installed with gcc --version or clang --version.
  2. Install a C compiler (like gcc or clang) if it’s not installed.
  3. Make sure the compiler is in your $PATH.
  4. Re-run the configure script.

Now, you should be able to compile and install software from source without any issues!

Photo of author

Nathan Kellert

Nathan Kellert is a skilled coder with a passion for solving complex computer coding and technical issues. He leverages his expertise to create innovative solutions and troubleshoot challenges efficiently.

Leave a Comment