Nearby lessons
9 of 124C - 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.
- Go to winlibs.com and download the latest UCRT runtime, Win64, ZIP archive.
- Extract the ZIP. You will get a folder named
mingw64. - Move that folder to
C:\mingw64— a short path with no spaces avoids trouble later. - Confirm that
C:\mingw64\bin\gcc.exeexists.
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.
- Press Win and search for Edit the system environment variables.
- Click Environment Variables…
- Under User variables, select Path and click Edit.
- Click New and type
C:\mingw64\bin - Click OK on all three dialogs.
- Close every open terminal and VS Code window, then reopen.
Linux — One Command
On Linux the compiler comes from your package manager, and the PATH is handled automatically:
macOS — Xcode Command Line Tools
macOS ships with Clang, which understands standard C and answers to the name gcc. Install the command line 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:
Troubleshooting
| Message | Cause | Fix |
|---|---|---|
'gcc' is not recognized | PATH not set, or terminal not restarted | Re-check the PATH entry, then open a new terminal |
command not found: gcc | Compiler not installed (Linux/macOS) | Run the install command above |
| Works in CMD but not in VS Code | VS Code was open before the PATH changed | Fully quit and reopen VS Code |
Access is denied | Extracted into a protected folder | Move mingw64 to C:\mingw64 |
where gcc on Windows or which gcc on Linux/macOS. If it prints nothing, the PATH is the problem — every time.- 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.