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. Linking a dynamic library in qt creator

Linking a dynamic library in qt creator

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 6.5k Views
  • 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.
  • F Offline
    F Offline
    firefox
    wrote on last edited by
    #1

    Hi,

    I'm working for first time with a 3rd party library(qxmpp). I'm on Window and I want to dynamically link the library during run time as the library is under LGPL and I've read it is recommended to use such libraries as dlls.

    This is what I've tried.

    1. Download the source code of library and built the .dll and .lib files.
    2. I've copied the header files into my project include folder and added them in .pro file under HEADERS variable.
    3. I've included the required header from library in .cpp file when I want to use a particular function from the library.
    4. I added the line LIBS+= -LC:/DLL -lqxmpp_d0 and placed the qxmpp_d0.dll and qxmpp_d0.lib in my C:/ drive.
    5. Tried to build my project and but I'm getting many warnings saying "inconsistent dll linkage" and
      errors saying "definition of dll import static date member is not allowd"
      6, I've googled the errors and find that error means I've tried to define a fucntion that is declared as will be picked from a external library. But I haven't done that. The code where the error comes up seems to be generated by MOC.

    I'm guessing I'm missing something obvious here. Can someone help me with this please.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2
      1. I've copied the header files into my project include folder and added them in .pro file under HEADERS variable

      That's not how you usually use external libraries. Instead of adding the headers into HEADERS (which adds them to your project) specify the path to where they are located in INCLUDEPATH.

      1. I added the line LIBS+= -LC:/DLL -lqxmpp_d0 and placed the qxmpp_d0.dll and qxmpp_d0.lib in my C:/ drive

      Maybe that's a typo but to be sure: you're adding -LC:/DLL as the directory so you should place the lib in C:/DLL, not C:/.

      Next questions:
      Have you run qmake after modifying your .pro file?
      Are you using the same compiler and the same Qt version to build the lib and your app?

      1 Reply Last reply
      2
      • F Offline
        F Offline
        firefox
        wrote on last edited by
        #3

        Thanks Chris.
        Following your steps worked.

        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