Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Linkage problem in Windows
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Linkage problem in Windows

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    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"
    @

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kainjow
      wrote on last edited by
      #2

      What errors are you getting?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        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.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          soroush
          wrote on last edited by
          #4

          [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 Reply Last reply
          0
          • D Offline
            D Offline
            dbzhang800
            wrote on last edited by
            #5
            1. Are you sure that you have export all these symbols?

            2. Run dumpbin to see the result if you are not sure.
              @
              dumpbin /EXPORTS dllfile.dll
              @

            3. 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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              soroush
              wrote on last edited by
              #6

              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).

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dbzhang800
                wrote on last edited by
                #7

                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).

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  soroush
                  wrote on last edited by
                  #8

                  [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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved