Domanda

I am new to C++ and I am now struggling with compiling and linking. Recently I have been using cmake and make to recompile a library (mlpack) that makes usage of Boost (Cmake does not find boost 1.51 (windows 8)).

In a first attempt, I downloaded precompiled binaries for windows. This did not work out well and I have been explained the binaries I was using were for MSVC, not MinGW, therefore troubles. And indeed, after recompiling boost using MinGW, things went ok.

Here I would just like to get an intuition what would be the differences between binaries for MSVC and MinGW. I (naively?) thought binaries were specific to OS/processor. What do the binaries for MSVC contains that make them unusable by MinGW ?

È stato utile?

Soluzione

It is relatively easy to combine artifacts (static/shared libraries) produced by MSVC and MinGW (this applies to other C compilers in general) as long as they export pure C API. This makes C API to be very portable and that's one of the main reasons why so many popular libraries still prefer to use pure C API.

The story with C++ is completely different. The most notorious obstacles for proper interoperability between artifacts produced by different C++ compilers are differences in name mangling and application binary interface (ABI). This applies to all C++ compilers in general, and not only MinGW and MSVC. If you want to learn more about interoperability pitfalls between MSVC and MinGW in particular, I encourage you to read the following articles:

  1. Interoperability of Libraries Created by Different Compiler Brands
  2. Binary-compatible C++ Interfaces

Altri suggerimenti

To be simple.

Windows speaks French.
MinGW speaks French, German and English.
Unix systems speak German.


The MSVC binaries are written in French.
The MinGW binaries are written in FrenchAngloGerman.
The UNIX binaries are written in German.


Windows needs MinGW to translate some of the German and English to French before it can understand everything.


MinGW is not like the other programs. It is basically a mini OS between Windows and Linux. So mostly it needs a modified form of binaries to work properly. The fact that you develop your program on Windows on MinGW doesn't mean they will run on pure Windows with out any problems. You still need to ship or distribute the MinGW libraries and executables that you used with your program.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top