Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Installing MinGW-w64 (GCC) on Windows: Options, Setup, and Verification

Tech 1

MinGW-w64 provides GCC-based C/C++ toolchains for Windows, targeting both 32-bit and 64-bit systems. It links against the native Windows runtime libraries, producing executables that run without third‑party runtime DLLs. Compared with the legacy MinGW project (32-bit only and largely unmaintained), MinGW-w64 remains actively updated and supports modern language standards.

When to use MinGW-w64

  • Command-line oriented development and learning the C/C++ build process
  • Small to medium projects where a lightweight toolchain is preferred
  • Cases where no external runtime dependency is desired
  • IDEs that bundle MinGW-w64 under the hood (e.g., Code::Blocks bundles, some VS Code setups)

Keep in mind that larger projects typically use build systems (Make, CMake, Ninja). Pure command-line flows require Makefiles or build scripts to scale beyond single-file builds.

Obtaining MinGW-w64 (official builds)

Typical installer choices (SourceForge builds)

  • Version: GCC release packaged by the distributor. Pick the latest unless a specific version is required.
  • Architecture:
    • x86_64: 64-bit Windows
    • i686: 32-bit Windows
  • Threads:
    • posix: POSIX threading model
    • win32: Windows threading model Choose based on library compatibility; posix is common for cross-platform builds, win32 for pure Windows targets.
  • Exceptions (64-bit):
    • seh (Structured Exception Handling): recommended for 64-bit
    • sjlj: legacy alternative
  • Exceptions (32-bit):
    • dwarf: usually faster unwinding for 32-bit, not for 64-bit
    • sjlj: portable but slower unwinding
  • Revision (build revision): Packager’s build number; default is fine.

Installation steps (SourceForge-style installer)

  1. Download the online or offline installer from the MinGW-w64 download page.
  2. Launch the installer.
  3. Select GCC Version, Architecture (x86_64 for 64-bit, i686 for 32-bit), Threads (posix or win32), and Exceptions (seh for 64-bit; dwarf for 32-bit unless sjlj is required).
  4. Choose an installation directory, for example:
    • C:\mingw-w64\x86_64-\
  5. Finish the installation and note the bin folder location, e.g. C:\mingw-w64\x86_64-...\mingw64\bin.

PATH configuration (Windows)

  • Add the toolchain’s bin directory to PATH so gcc and g++ are available in shells.

    • System Properties → Environment Variables → Edit PATH → add C:\mingw-w64...\mingw64\bin
    • Or from a elevated Command Prompt:

    setx PATH "%PATH%;C:\mingw-w64\x86_64-...\mingw64\bin"

Verification

  • Open a new terminal and check versions:

    gcc --version g++ --version where gcc

    Example output (will vary by build):

    gcc (x86_64-posix-seh, Built by MinGW-W64 project) 13.2.0 Copyright (C) 2023 Free Software Foundation, Inc.

  • Build and run a small program:

    Save as hello.c:

    #include <stdio.h>

    int main(void) { puts("Hello from MinGW-w64!"); return 0; }

    Compile and run:

    gcc -O2 -Wall -Wextra -o hello.exe hello.c .\hello.exe

    Expected output:

    Hello from MinGW-w64!

Common selector guidance

  • 64-bit targets: x86_64 + seh; threads either posix (portabel libs) or win32 (pure Windows)
  • 32-bit targets: i686 + dwarf; use sjlj only if required by specific libraries
  • Choose the newest stable GCC unless compatibility requirements dictate otherwise

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.