How can one link Visual C++ (2010) console app with a STATIC library created by MinGW
(*.a
format)? Is it compatible with Visual C++ 2010?
Thank you.
How can one link Visual C++ (2010) console app with a STATIC library created by MinGW
(*.a
format)? Is it compatible with Visual C++ 2010?
Thank you.
It's not compatible.
However, if you extract all the object files from the library (use
ar
), the VC++ linker is able to deal with those (I tested it, although I used cygwin gcc rather than mingw gcc). Note that you may still have name mangling problems if you don't useextern "C"
.You may of course use VC++'s
LIB.EXE
tool to make these into a static library in VC++ format.As @Michael points out, you will definitely have problems if you try to pass non-POD C++ objects between modules built with different compilers. The fix for this is the same as the DLL case: write a wrapper built with the same compiler (in this case mingw) that exposes a C-compatible interface usable from other toolchains.