[SOLVED] Linkage problem in Windows



  • I have a problem with linking things in windows using Qt. After hours of struggling, I found that any library that I compile, could not be linked against neither by MingW nor MSVC 2010 linkers. I have tried to use a test shared library (foo) in a test application (bar). No success...

    bar.pro:
    @
    LIBS += -lfoo # libfoo.a and foo.dll are in a visible path

    also tried absoluted paths:

    LIBS += "c:/path/to/dllfile.dll"

    and also:

    LIBS += "c:/path/to/somename.a"
    @



  • What errors are you getting?


  • Moderators

    You are aware of that the outputs of the different compilers are not compatible?
    You cannot mix objs and libs of different versions of msvc (e.g. 2005, 2008, 2010) and not with mingw.
    You need to make sure that all is compiled with the same compiler.



  • [quote author="kainjow" date="1337797377"]What errors are you getting?[/quote]

    a lot of undefined references

    [quote author="koahnig" date="1337797661"]You are aware of that the outputs of the different compilers are not compatible?
    You cannot mix objs and libs of different versions of msvc (e.g. 2005, 2008, 2010) and not with mingw.
    You need to make sure that all is compiled with the same compiler.[/quote]

    Yes, I'm sure about binary compatibility. I compiled both plugin and application with MinGW 4.4 32 bit, Both from command-line and Qt Creator.



    1. Are you sure that you have export all these symbols?
    1. Run dumpbin to see the result if you are not sure.
      @
      dumpbin /EXPORTS dllfile.dll
      @

    2. If you are not familiar with how to create shared library under windows. Please ref MSDN:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms682592(v=vs.85).aspx

    In addition, Qt has provide some macros to ease the creation of shared library.
    http://qt-project.org/doc/qt-4.8/sharedlibrary.html



  • Output of dumpbin /EXPORTS agtplugin.dll:
    @
    Dump of file .\agtplugin.dll
    File Type: DLL
    Section contains the following exports for agtplugin.dll
    00000000 characteristics
    4FBD190B time date stamp Wed May 23 21:36:19 2012
    0.00 version
    1 ordinal base
    2 number of functions
    2 number of names
    ordinal hint RVA name
    1 0 00001B80 qt_plugin_instance
    2 1 00001A20 qt_plugin_query_verification_data
    Summary
    1000 .bss
    5000 .data
    1000 .edata
    3000 .idata
    7000 .rdata
    2000 .reloc
    11000 .text
    @

    @1+1=2: I think there is something wrong here. (I have more than 2 functions.) You're right , symbols are not exported correctly.

    However I don't know how to create a symbol table in dll file. Trying to add __declspec(dllexport) before each function declaration didn't help. Also adding that keyword before slots, cause a compile error (MinGW).



  • From the information we can see that what you created is a normal Qt plugin(add the proper functions have been exported), but I could not understand why you want to use it as a normal shared library(though it really works if you export proper symbols).



  • [quote author="1+1=2" date="1337893478"]From the information we can see that what you created is a normal Qt plugin(add the proper functions have been exported), but I could not understand why you want to use it as a normal shared library(though it really works if you export proper symbols).[/quote]

    Because I'm lazy and don't want to change structure of project ;) Seriously, I tried to separate widget library and designer plugin. The plugin successfully linked to widget library. Also client applications linked against it. but there was no success with Qt designer. Current library (widget and plugin in same binary) works in both windows and Linux. But in windows, designer plugin for Qt creator doesn't work, because of "build key mismatch.":http://doc.qt.nokia.com/qtcreator-2.4/adding-plugins.html#matching-build-keys I'm gonna correct it tonight.

    Thanks


Log in to reply
 

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