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] Problem with external library linking under Windows

[SOLVED] Problem with external library linking under Windows

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.3k Views 2 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Hi,
    I'm trying to link BerkeleyDB library (libdb), which I have compiled using MinGW, inside my Qt W32 App (using QtCreator 3.4.1 (MinGW)).
    Unfortunately, I'm getting the error "error: cannot find -llibdb-6.1.dll", after compiling, and I'm still not finding any way to solve this issue.

    This is the library configuration code in the .pro file:

    @ win32: LIBS += -LC:/msys/1.0/local/lib/ -llibdb-6.1.dll
    else:unix: LIBS += -llibdb @

    Thanks for your help.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi, welcome to devnet.

      .dll is a shared library loaded at runtime. The compiler and linker need know nothing about it.

      LIBS should contain a path to the compile time library (.lib for MSVC and .a for MinGW) and you don't need to specify the file extension so in this case it should be LIBS += -LC:/msys/1.0/local/lib -llibdb-6.1, assuming a file C:/msys/1.0/local/lib/libdb-6.1.a exists at that location.

      ? 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        Hi, welcome to devnet.

        .dll is a shared library loaded at runtime. The compiler and linker need know nothing about it.

        LIBS should contain a path to the compile time library (.lib for MSVC and .a for MinGW) and you don't need to specify the file extension so in this case it should be LIBS += -LC:/msys/1.0/local/lib -llibdb-6.1, assuming a file C:/msys/1.0/local/lib/libdb-6.1.a exists at that location.

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        @Chris-Kawa said:

        Hi, welcome to devnet.

        .dll is a shared library loaded at runtime. The compiler and linker need know nothing about it.

        LIBS should contain a path to the compile time library (.lib for MSVC and .a for MinGW) and you don't need to specify the file extension so in this case it should be LIBS += -LC:/msys/1.0/local/lib -llibdb-6.1, assuming a file C:/msys/1.0/local/lib/libdb-6.1.a exists at that location.

        Well, I used -llibdb-6.1.dll instead of -llibdb-6.1, because the static library was generated as libdb-6.1.a while the dynamic one was generated as libdb-6.1.dll.a (and I'm using the dynamic one). But, the library file libdb-6.1.dll.a already exists in the C:/msys/1.0/local/lib directory.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok, tle .dll part got me off track. Hm, if the file is there then it should work.
          If I remember correctly the gcc linker (so I guess MinGW too) prepends "lib" automatcally so could you try -ldb-6.1.dll instead?
          Also, just to prove it's not a name problem could you rename it to something like "test.a" and link to -ltest?

          ? 1 Reply Last reply
          1
          • Chris KawaC Chris Kawa

            Ok, tle .dll part got me off track. Hm, if the file is there then it should work.
            If I remember correctly the gcc linker (so I guess MinGW too) prepends "lib" automatcally so could you try -ldb-6.1.dll instead?
            Also, just to prove it's not a name problem could you rename it to something like "test.a" and link to -ltest?

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @Chris-Kawa said:

            Ok, tle .dll part got me off track. Hm, if the file is there then it should work.
            If I remember correctly the gcc linker (so I guess MinGW too) prepends "lib" automatcally so could you try -ldb-6.1.dll instead?
            Also, just to prove it's not a name problem could you rename it to something like "test.a" and link to -ltest?

            Sorry for the late reply.
            Yes, It works fine now after changing to -ldb-6.1.dll. Thanks a lot!

            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