The easiest way to install GCC on Windows 11 or Windows 10 is through MSYS2, which provides an up-to-date MinGW-w64 version of GCC. Install MSYS2 from msys2.org, open the MSYS2 UCRT64 terminal, and run pacman -S mingw-w64-ucrt-x86_64-gcc. Then add C:\msys64\ucrt64\bin to your Windows Path so you can run gcc and g++ from Command Prompt, PowerShell, or VS Code. Type gcc --version to confirm it worked.
Which option is right for you?
| Option | Best for |
|---|---|
| MSYS2 (MinGW-w64 GCC) | Most people who want gcc and g++ on Windows |
| WSL (Linux GCC) | Linux-style development and tools like make |
| Visual Studio (MSVC) | Windows apps and the Visual Studio IDE, not GCC |
Method 1: Install GCC with MSYS2
Step 1: Install MSYS2
- Go to msys2.org and download the installer, or run
winget install MSYS2.MSYS2in Terminal. - Run the installer and keep the default folder, C:\msys64.
- When it finishes, leave Run MSYS2 now checked and click Finish.
Step 2: Update MSYS2 and install GCC
- Open MSYS2 UCRT64 from the Start menu.
- Run
pacman -Syuto update. If the window closes, open MSYS2 UCRT64 again and runpacman -Syuonce more. - Run
pacman -S mingw-w64-ucrt-x86_64-gccand press Enter, then Y to confirm. - Run
gcc --version. You should see the installed version.

For debugging and build tools too, run pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain. This adds gdb, make, and more.
Step 3: Add GCC to your Windows Path
- Click Start, type environment variables, and open Edit the system environment variables.
- Click Environment Variables.
- Under User variables, select Path and click Edit.
- Click New, type C:\msys64\ucrt64\bin, and click OK in each window.
- Open a new Command Prompt or PowerShell window and run
gcc --versionandg++ --version.
Test it with a Hello World program
- Create a file named hello.c with this code:
#include <stdio.h>
int main(void) { printf("Hello, world!\n"); return 0; } - In the same folder, run
gcc hello.c -o hello.exe. - Run
.\hello.exe. You should see Hello, world!
For C++, save the file as hello.cpp and compile with g++ hello.cpp -o hello.exe.
Method 2: Use GCC in WSL
- Open Terminal (Admin) and run
wsl --install. Restart when asked. - Open Ubuntu from the Start menu and create a Linux username and password.
- Run
sudo apt update, thensudo apt install build-essential. - Run
gcc --versionto confirm.
Programs built in WSL are Linux programs. They run inside WSL, not as regular Windows .exe files.
Use GCC with VS Code
- Install Visual Studio Code and the C/C++ extension from Microsoft.
- Open your project folder, open a .c or .cpp file, and choose Run > Run Without Debugging.
- When asked, choose the C/C++: gcc.exe or g++.exe build task from C:\msys64\ucrt64\bin.
Troubleshooting
- “gcc is not recognized”: The Path isn’t set or you’re using an old window. Recheck Step 3 and open a new terminal.
- Wrong gcc runs: An older MinGW is earlier in your Path. Run
where gccto see which one Windows finds, and remove the old folder from Path. - Antivirus flags your .exe: Brand-new compiled programs sometimes trigger false positives. Add your project folder as an exclusion if you trust the code.
Frequently asked questions
Is MinGW the same as GCC?
MinGW-w64 is a version of the GCC toolchain built to create Windows programs. MSYS2 is the easiest way to install and update it.
Should I use the old MinGW installer from SourceForge?
No. The original MinGW project is outdated. Use MinGW-w64 through MSYS2 instead.
What’s the difference between UCRT64 and MINGW64?
Both make 64-bit Windows programs. UCRT64 uses Microsoft’s newer Universal C Runtime and is the recommended default.
Is this the same on Windows 10?
Yes. The steps are identical on Windows 10 and Windows 11.

Kermit Matthews is a freelance writer based in Philadelphia, Pennsylvania with more than a decade of experience writing technology guides. He has a Bachelor’s and Master’s degree in Computer Science and has spent much of his professional career in IT management.
He specializes in writing content about iPhones, Android devices, Microsoft Office, and many other popular applications and devices.