Nearby lessons

9 of 124

C - Install C Compiler

How to install the GCC C compiler — MinGW-w64 on Windows, build-essential on Linux, Xcode command line tools on macOS — and how to add it to the PATH so gcc works from any terminal.

Windows — Install MinGW-w64

GCC does not ship with Windows, so you install a Windows build of it called MinGW-w64. The simplest source is winlibs.com, which provides a ready-made ZIP with no installer.

  1. Go to winlibs.com and download the latest UCRT runtime, Win64, ZIP archive.
  2. Extract the ZIP. You will get a folder named mingw64.
  3. Move that folder to C:\mingw64 — a short path with no spaces avoids trouble later.
  4. Confirm that C:\mingw64\bin\gcc.exe exists.
In simple words: there is nothing to "install" — you are just placing a folder of tools on your disk. The only remaining job is telling Windows where that folder is.

Windows — Add GCC to the PATH

The PATH is the list of folders your terminal searches when you type a command. If C:\mingw64\bin is not on it, typing gcc fails even though the file exists.

  1. Press Win and search for Edit the system environment variables.
  2. Click Environment Variables…
  3. Under User variables, select Path and click Edit.
  4. Click New and type C:\mingw64\bin
  5. Click OK on all three dialogs.
  6. Close every open terminal and VS Code window, then reopen.
The step everyone forgets: a terminal reads the PATH once, when it starts. If you edit the PATH while a terminal is open, that terminal keeps the old value forever. Always restart it.

Linux — One Command

On Linux the compiler comes from your package manager, and the PATH is handled automatically:

Example03
CCode Cell
1# Ubuntu / Debian / Mint
2sudo apt update
3sudo apt install build-essential
4 
5# Fedora / RHEL / CentOS
6sudo dnf groupinstall "Development Tools"
7 
8# Arch / Manjaro
9sudo pacman -S base-devel
Output
Setting up gcc (4:13.2.0-7ubuntu1) ...
Setting up build-essential (12.10ubuntu1) ...

macOS — Xcode Command Line Tools

macOS ships with Clang, which understands standard C and answers to the name gcc. Install the command line tools:

Example04
CCode Cell
1xcode-select --install
Output
xcode-select: note: install requested for command line developer tools

Verify — The Only Test That Matters

Open a new terminal and run both commands. The first checks the compiler, the second checks the debugger you will need later:

Example05
CCode Cell
1gcc --version
2gdb --version
Output
gcc (MinGW-w64 13.2.0) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.

GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.

Troubleshooting

MessageCauseFix
'gcc' is not recognizedPATH not set, or terminal not restartedRe-check the PATH entry, then open a new terminal
command not found: gccCompiler not installed (Linux/macOS)Run the install command above
Works in CMD but not in VS CodeVS Code was open before the PATH changedFully quit and reopen VS Code
Access is deniedExtracted into a protected folderMove mingw64 to C:\mingw64
Trainer's Note: To see exactly which gcc your terminal found, run where gcc on Windows or which gcc on Linux/macOS. If it prints nothing, the PATH is the problem — every time.
📝 Key Takeaways
  • GCC is the compiler; MinGW-w64 is the Windows build of it.
  • The PATH tells your terminal where to find gcc.exe.
  • On Windows, add the compiler's bin folder to PATH manually.
  • Restart the terminal after changing the PATH — it is read at startup.
  • gcc --version confirms everything worked.

🧠 Test Your Knowledge

3 Questions
Progress: 0 / 3