Important: Please read the Qt Code of Conduct -

[SOLVED]Ways to include MFC library in MinGw

  • Hi all,
    From a supplier I got a driver and libraries to include into my project to handle CAN to USB communications. The dll comes with a header file and a lib file. The library is compiled with some kind of VC (visual C?) compiler, but an example program was also given using Visual Studio 2008. I'm just guessing, but that is probably also the compiler used for the dll creation.
    For my own project I use the MinGw4.7 compiler delivered with the Qt5.0.1 SDK and I don't want to switch it to the Visual Studio because Microsoft is getting more and more cumbersome about licenses etc.
    The real big question now is how to get that MSVC2008 lib into my MinGw project.
    the things I tries:

    • static linking (just include the header file and add the library to the project with the library add-wizard), but the program crashed before it begins (code: 0xc0000318).
    • Dynamic linking with QLibrary, but that just returns false when trying to open the library and resolve naturally returns 0 for the requested function.

    My biggest question is if it is indeed possible to use the MSVC2008 library in a MinGw project with dynamic linking? If so, HOW?? Working on it all afternoon with no luck.
    Any help would be very much appreciated.

  • Moderators

    i think thats not possible... since the library is compiled with MSVC.
    I believe that mingw wont understand the exported symbols by the MSVC compiler.
    But i would like to be proven wrong ;)

    Edit: found "this useful link":
    Edit2: see also "this topic":

    1. Which API don't these driver and libraries provided. C or C++ ?
      As far as i know, most of low level APIs are provided through C API.

    2. If C++ API is provided, you can try to make a C wrapper using VC. Then the wrapper can be used directly by your MinGW.

  • Moderators

    indeed... what i forgot to mention in my previous post was:
    The incompatibility only exists for exported C++ symbols/methods, but not for exported C methods (Hint: extern "C" {...})

  • Hee,
    Thanks for the advice and the manufacturer gave me an usable C API instead of the C++ API build with MSVC2012. That solved the problem for me and you guys help me understand the problem.
    It all has to do with name mangling between compilers (even different MSVC compiler are not able to be used together) Shouldn't they standardize this, would make our work a bit easier ;-)

Log in to reply