Skip to content
gcc: command not found

gcc: command not found

DodaTech 2 min read

The gcc: command not found error means the GNU C Compiler is not installed. It appears when trying to compile C programs but the compiler is missing.

What It Means

The shell cannot locate the gcc binary in any directory listed in your PATH environment variable. GCC is not installed by default on most systems — you need to install it explicitly for your platform.

Why It Happens

  • GCC is not installed on the system at all
  • You’re on a minimal system (Docker container, fresh OS install) without development tools
  • On Windows, GCC isn’t included and requires MinGW or WSL
  • The PATH does not include the GCC installation directory

How to Fix It

Step 1: Install GCC on Debian/Ubuntu

sudo apt update
sudo apt install gcc

Verify the installation:

gcc --version

Step 2: Install GCC on Fedora/RHEL

sudo dnf install gcc

Step 3: Install GCC on macOS

Install Xcode Command Line Tools which includes GCC:

xcode-select --install

Step 4: Install GCC on Windows

Download MinGW-w64 from mingw-w64.org or use Chocolatey:

choco install mingw

Alternatively, enable WSL (Windows Subsystem for Linux) and install GCC inside the Linux environment.

Step 5: Verify the installation

Create a test C program and compile it:

// hello.c
#include <stdio.h>

int main() {
    printf("Hello, GCC!\n");
    return 0;
}
gcc hello.c -o hello
./hello

Expected output:

Hello, GCC!
What is the difference between gcc and g++?
gcc compiles C code, while g++ compiles C++ code. Both are part of the GNU Compiler Collection. If you only need to compile C programs, installing gcc is sufficient. For C++, you also need g++.
Can I use Clang instead of GCC?
Yes. On macOS, clang is often installed as gcc via the Xcode toolchain. You can also install Clang on Linux with sudo apt install clang and use it the same way: clang hello.c -o hello.
How do I check if GCC is already installed?
Run which gcc or gcc --version. If GCC is installed, which returns the path to the binary, and --version prints version information. If neither works, GCC is not installed or not in your PATH.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro