Qlibrary on C++ DLL



  • Hello all, I have a dll that was compiled under MSVC 2008, I have it's lib and header files but not the source code.
    I tried using neither dlltool and reimp commands to rebuild a '.a' library file but it didn'--t work.

    so, my question is, can I use QLibrary, or any other Qt class to init instances of these classes
    knowing they are mostly singletones, like:
    @ static SomeClass * SomeClass::instance();@
    so I have to somehow call these function.

    thanks,
    G



  • Hello,

    Is this a C library or a C++ one?
    You could use QLibrary with C, and construct your own objects after....
    However i am quite sure that's it's difficult to embed C++ object, as they are using the MFC, and sometimes they have some impredictible reactions, so it depends on your objects.
    But it is not a very good practice i think.



  • [quote author="dmcr" date="1319556052"]However i am quite sure that's it's difficult to embed C++ object, as they are using the MFC, and sometimes they have some impredictible reactions, so it depends on your objects.
    But it is not a very good practice i think.[/quote]

    Correct, although not related to MFC. MSVC c++ libraries are binary incompatible to MinGW libraries. MSVC built C++ libraries are often even binary incompatible between MSVC versions. The only way you're going to be able to use it (if it's a C++ interface) is by using a corresponding MSVC version for your build. This sort of thing is the precise reason Qt is distributing binaries for both MSVC and MinGW. Pain in the butt? Certainly. Blame the C++ guys for leaving the ABI free to choose.



  • thanks... I see if I can get the vendor to be a bit more.. relaxed... :-)

    thanks,
    G



  • Hi !
    Did you find any solution for your problem ? I'm in the same case (a C++ library compiled with MSVC) and I want to add it in a GCC compiled project...

    Is there any way to re-compile the library ? or build an inclusion file (like a .lib) in order to help the linker ?

    Thanks.



  • The sanest way to work around this I think is to wrap the C++ dll in a C interface dll (using msvc express). Then you can use gcc to (dynamically) link against that. C linkage is defined, unlike C++. It's usually the easiest if the vendor doesn't supply mingw builds (like Qt does).



  • yes:
    [quote author="Franzk" date="1328548005"]The sanest way to work around this I think is to wrap the C++ dll in a C interface dll (using msvc express). Then you can use gcc to (dynamically) link against that. C linkage is defined, unlike C++. It's usually the easiest if the vendor doesn't supply mingw builds (like Qt does).[/quote]

    this was my first solution, then I got enough budget to re-implement the stuff, so everything now is MSVC...
    because of the difference between GCC and MSVC, there is no other way then to warp the DLL (many tutorials on the web on this). or go MSVC/GCC all the way.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.