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.