This guide shows you how to install GCC on Windows 11 so you can compile and run C programs. Windows does not come with a C compiler, so we will install MinGW-w64 (the Windows port of GCC) using MSYS2 — the modern, actively maintained way to get GCC on Windows.
Not ready to install anything yet? You can write and run C programs directly in your browser — see our guide to online C compilers instead. No installation needed, ideal if you just have one or two programs to compile.
Why MSYS2 and Not the Old MinGW Installer?
If you have seen older tutorials pointing to “mingw-get” or a standalone MinGW installer, skip them. That project is no longer maintained and ships an ancient GCC version. MSYS2 gives you MinGW-w64 with a current GCC, security updates, and a simple package manager (pacman) to keep it up to date. This is what the GCC project itself recommends for Windows today.
Prerequisites
- A PC running Windows 11 (these steps also work on Windows 10)
- About 2 GB of free disk space
- An internet connection
Step 1 — Download MSYS2
Go to the official site msys2.org and download the installer (a file named something like msys2-x86_64-XXXXXXXX.exe). Always download from the official site — never from a mirror or third party.
Step 2 — Run the Installer
- Run the downloaded
.exe - Accept the default install location (
C:\msys64) — this keeps later commands simple - Click through Next until installation finishes
- Leave Run MSYS2 now ticked and click Finish
A dark terminal window opens. This is the MSYS2 shell — you will run the next commands here.
Step 3 — Update MSYS2
Before installing GCC, update the package database. In the MSYS2 terminal, type:
pacman -Syu
When prompted, type Y and press Enter. The terminal may close itself at the end of the update — this is normal. Reopen it from the Start menu (search for MSYS2 MINGW64) and run the update once more to finish:
pacman -Su
Step 4 — Install the GCC Toolchain
Now install MinGW-w64 GCC and the essential build tools:
pacman -S mingw-w64-ucrt-x86_64-gcc
Press Enter to accept the default selection, then Y to confirm. This installs GCC, the C standard library, and supporting tools. The download is around a few hundred megabytes.
To also get gdb (the debugger) and make, install the full toolchain instead:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
Step 5 — Add GCC to the Windows PATH
So you can run gcc from any terminal (Command Prompt, PowerShell, or VS Code) — not just the MSYS2 shell — add it to your PATH:
- Press Win and type environment variables
- Click Edit the system environment variables
- Click Environment Variables…
- Under System variables, select Path and click Edit
- Click New and add:
C:\msys64\ucrt64\bin - Click OK on all dialogs
Close and reopen any terminal windows for the change to take effect.
Step 6 — Verify the Installation
Open a regular Command Prompt or PowerShell (not the MSYS2 shell) and type:
gcc --version
You should see something like:
gcc.exe (Rev3, Built by MSYS2 project) 14.x.x Copyright (C) 2024 Free Software Foundation, Inc.
If you see a version number, GCC is installed and on your PATH. If you get 'gcc' is not recognized, recheck Step 5 — the PATH entry must point to C:\msys64\ucrt64\bin.
Step 7 — Compile and Run Your First Program
Create a file called hello.c in any folder with this content:
#include <stdio.h>
int main(void) {
printf("Hello from Windows 11!\n");
return 0;
}
Open Command Prompt, navigate to that folder with cd, and run:
gcc hello.c -o hello.exe
hello.exe
Output:
Hello from Windows 11!
On Windows the executable ends in .exe, and you run it by typing its name (no ./ needed, unlike macOS and Linux).
Common Issues
| Problem | Fix |
|---|---|
'gcc' is not recognized as an internal or external command |
PATH not set — recheck Step 5, then open a fresh terminal |
'pacman' is not recognized |
You are in Command Prompt, not the MSYS2 shell — run pacman commands in the MSYS2 terminal |
| The MSYS2 terminal closed during update | Normal during pacman -Syu — reopen and run pacman -Su |
| Antivirus blocks the download | MSYS2 is safe — download only from msys2.org and allow it through |
| Old MinGW already on PATH | Remove the old MinGW PATH entry so it does not shadow the new GCC |
What’s Next
Now that GCC is installed, learn the full compile-and-run workflow — including warning flags and multiple source files — in our guide: How to Run a C Program on Windows 11.
Prefer a full IDE with code completion and one-click compiling instead of the command line? VS Code is the best free option and works seamlessly with the MSYS2 GCC you just installed.
Once your environment is ready, browse our full list of C programs with examples to start practising.
As an Amazon Associate we earn from qualifying purchases.
Recommended Book
The best book to learn C once your environment is set up — The C Programming Language by Brian Kernighan and Dennis Ritchie (K&R). Concise, precise, and still the definitive reference decades on.