Skip to content

MinGW

✅ WHAT IS MinGW?

MinGW = Minimalist GNU for Windows

  • A Windows port of the GCC (GNU Compiler Collection).
  • Lets you compile C, C++, Fortran, and other languages on Windows using GCC.
  • Outputs native Windows binaries—no dependency on a POSIX layer like Cygwin.

Key Components:

  • gcc – C compiler
  • g++ – C++ compiler
  • gfortran – Fortran compiler
  • binutils – tools like ld, as, ar
  • mingw32-make – Make utility (Windows-compatible make)

✅ WHY USE MinGW?

  1. GCC on Windows – Use familiar GNU toolchain.
  2. Cross-platform builds – Build software that compiles on Linux and Windows.
  3. No runtime overhead – Produces native .exe files without needing a POSIX emulation layer.
  4. Tooling – Works with CMake, Makefiles, and common open-source build systems.

🔁 ALTERNATIVES TO MinGW

Tool Description
MSVC (Microsoft Visual C++) Official compiler for Windows development. Best for Windows APIs and Visual Studio users.
Clang/LLVM for Windows Modern, modular compiler. Fast and standards-compliant. Cross-platform.
Cygwin Full POSIX emulation on Windows. Not lightweight. Adds overhead.
WSL (Windows Subsystem for Linux) Not a compiler but allows you to run GCC in a Linux environment on Windows.
TDM-GCC GCC variant for Windows, preconfigured with sane defaults.
MYSYS2 Provides MinGW-w64 with package manager (pacman). Very useful.

🔥 Best alternative for serious development: MSYS2 with MinGW-w64 – better packaging, active updates.


🛠️ HOW TO SET UP MinGW (Classic)

OPTION 1: Classic MinGW (outdated but simple)

  1. Go to MinGW SourceForge
  2. Download the MinGW Installer (mingw-get-setup.exe)
  3. Run the installer and select these packages:

  4. mingw32-base

  5. mingw32-gcc-g++
  6. (optional) mingw32-gcc-fortran
  7. mingw32-make
  8. Install to C:\MinGW
  9. Add to PATH:

C:\MinGW\bin
6. Test it in a terminal:

gcc --version
g++ --version
mingw32-make --version

⚠️ Downside: Classic MinGW is outdated and missing C99/C11 features, no 64-bit support.


🛠️ HOW TO SET UP MinGW-w64 (Modern Fork)

  1. Download MSYS2: https://www.msys2.org/

  2. Install MSYS2 and open MSYS2 MSYS terminal

  3. Update package database:

pacman -Syu

Then restart terminal and run:

pacman -Su
  1. Install 64-bit MinGW toolchain:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make
  1. Use the MSYS2 MinGW 64-bit terminal for building.

  2. Add to PATH (optional):

C:\msys64\mingw64\bin
  1. Test:
gcc --version
g++ --version

📌 Summary

Setup Type Status 64-bit Recommended
MinGW Outdated
MinGW-w64 (via MSYS2) Active
MSVC Native to Windows ✅ (for Windows devs)

If you just want a GCC-based compiler on Windows that supports 64-bit and modern C/C++ standards, use MSYS2 with MinGW-w64. If you're targeting Windows-specific APIs or need IDE integration, use MSVC.