Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Linking libraries during build vs. install
Qt 6.11 is out! See what's new in the release blog

Linking libraries during build vs. install

Scheduled Pinned Locked Moved Installation and Deployment
2 Posts 2 Posters 1.5k 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.
  • X Offline
    X Offline
    xarxer
    wrote on last edited by
    #1

    Hello all. I have a problem regarding linking of shared libraries (I'll refer to them as .so files since I'm on linux).
    Let's say I have project A and project B. Project A builds as an executable file and project B builds as a .so

    My project tree looks like this:

    • Root

      • A
      • B

    And this is also what it looks like in my build directory.
    These projects installs to /usr/bin and /usr/lib respectively.

    Now, how do I go about to make it so that I can link to the installed version of project B (i.e. /usr/lib/B.so) when I compile project A?

    The chain of operations look like this: build B, build A, install B, install A.
    But if I declare LIBS += -L/usr/lib -lB in project A, it will look for the installed library, which isn't there during compile.

    Should I declare something like LIBS += -L<buildDirectory>/lib -L/usr/lib -lB?

    I'm sorry if this is too incoherent, but I hope someone will understand my problem!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you install B after compiling A you have to link A to the B library in the build directory simply because B is not yet installed. And you'd better do this anyway, since if you change B and want to relink A to B, it would link to the installed and not newly built B.

      To sum up:

      @LIBS += -L<buildDirectory>/lib -lB@

      Otherwise you have to build B, install B, build A, install A

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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