Search code examples
mingwmingw32mingw-w64

Why do MinGW binaries have such complicated names? (e.g. i686-w64-mingw32-...)


Looking at the mingw binaries presently on my system, I generally have i686-w64-mingw32-* and x86_64-w64-mingw32-* commands.

I presume that the former compile 32-bit Windows executables, and the latter compile 64-bit Windows executables.

What, then, do w64 and mingw32 signify in the names of these binaries?

Would there be any meaning to a w32 binary, e.g. i686-w32-mingw32-gcc? I suppose mingw32 is what it is because the project used to be called mingw32 and was renamed to MinGW.


Solution

  • MinGW is based on GCC and binutils, along with other GNU software. GNU projects use so-called "GNU triplets" to specify architecture information. A triplet has this format:

    machine-vendor-operatingsystem
    

    The triplet was specified when the binaries were built.

    MinGW-w64 is using w64 as the vendor field, and mingw32 as the operating system. Of course, mingw32 is not an operating system, but it is treated as one by the GCC and binutils build system and source code.

    So these long names for the binaries are an artifact of the build system that GCC and binutils are using. All of these binaries are installed in the same directory, and so binaries that target different architectures (in this case 32-bit vs 64-bit) need to have different file names. The easiest way to do that is to prefix the binaries with the GNU triplet that describes those architectures.