MinGW-w64 provides a native build of the GNU compiler toolchain for Windows, which is what lets you compile and run C and C++ programs without a virtual machine or WSL. This guide covers installing it on Windows 10, putting it on your PATH, and confirming it actually works.
Step 1 — Choose a build
The original MinGW project only targets 32-bit. MinGW-w64 is the actively maintained fork that supports both 32-bit and 64-bit, and it is the one you want.
The most reliable way to get it is a prebuilt package rather than compiling it yourself. Two good options:
- WinLibs — standalone prebuilt archives. Nothing to install, just extract.
- MSYS2 — a full package manager, useful if you later need libraries beyond the compiler.
This guide uses the standalone archive, because it is the fastest path to a working compiler.
Step 2 — Pick the right variant
Download pages list several builds, and the names are cryptic. Two choices matter:
Threading model — posix or win32. Choose posix. The win32 variant does not support the C++ standard threading library, so std::thread and std::mutex will not compile.
Exception handling — SEH or Dwarf. For 64-bit choose SEH. For 32-bit you will generally get Dwarf.
So on a modern 64-bit machine: the x86_64 build, posix threads, seh exceptions.
Step 3 — Extract it
Extract the archive to a path with no spaces in it. This matters more than it should — some build tools still handle spaced paths badly.
A good choice:
Avoid C:\Program Files\, precisely because of the space. After extracting you should have C:\mingw64\bin containing gcc.exe, g++.exe and gdb.exe.
Step 4 — Add it to your PATH
Without this step Windows will not find the compiler, and you will get gcc is not recognized as an internal or external command.
-
1.
Press
Win + R, typesysdm.cpl, press Enter.
- 2. Go to the Advanced tab and click Environment Variables.
- 3. Under User variables, select Path and click Edit.
-
4.
Click New and add the
bindirectory:
- 5. Click OK on every dialog to close them.
Close any terminal you already have open. A running terminal keeps the environment it started with, and will not see the change — this is the single most common reason people think the install failed.
Step 5 — Verify the installation
Open a new Command Prompt or PowerShell window and run:
Each should print a version banner. If so, the toolchain is installed and on your PATH.
Step 6 — Compile something
Create hello.c:
Compile and run it:
And the C++ equivalent, hello.cpp:
If both print their message, you have a complete working toolchain.
Common problems
gcc is not recognized — PATH is wrong or the terminal is stale. Confirm C:\mingw64\bin really contains gcc.exe, then open a *new* terminal. To check what Windows is actually searching, run echo %PATH%.
std::thread has not been declared — you installed the win32 threading variant. Reinstall the posix build; nothing else will fix this.
The program compiles but will not run on another machine — it depends on DLLs from your bin folder. Link statically instead:
VS Code does not find the compiler — it inherits the environment from however it was launched. Close it completely and reopen it after changing PATH.
Warnings you should not ignore. Compile with warnings enabled and read them:
Useful flags
The -g flag is what makes gdb useful, so keep it on while you are still developing.
Next steps
With the toolchain in place you can point an editor at it — VS Code with the C/C++ extension will pick up gcc from your PATH automatically once it is set correctly. From there, gdb gives you breakpoint debugging, and make is worth learning as soon as your project outgrows a single source file.
About the Author: gs_admin
A senior technical contributor specializing in architectural designs, software optimization, database structures, and developer education. Passionate about writing clean code and sharing engineering knowledge.