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 library statically
Qt 6.11 is out! See what's new in the release blog

Linking a library statically

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • J Offline
    J Offline
    Jyang772
    wrote on last edited by
    #1

    I have already built a static version of Qt following this "tutorial":http://qt-project.org/wiki/Building_Qt_5_from_Git

    Now how do I add a library to my project statically?

    The library is: libxcb-render-util.so.0
    located in: /usr/lib/x86_64-linux-gnu

    Do I right click on the project and select "Add Library..."? Which setting do I pick afterwards?
    I don't see an option to add statically.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      The linker automatically detects the library type. In your case the library is not static! On Unix, *.so is reserved for shared libraries (so == shared object), and *.a suffix denotes a static library.

      To add a library to your project, just add LIBS+=-Llibrary/dir -lmyLibName

      (Z(:^

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jyang772
        wrote on last edited by
        #3

        Okay,

        Also, when I run my application on a different computer I get this message:

        @error while loading shared libraries: libxcb-render-util.so.0: cannot open shared object
        @

        Do you think if I added the library libxcb-render-util.a , it would fix this dependency issue?

        Thanks!

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Yes, in a way it might work. Although the preferred way on Linux is to use a Packaga Manager to manage dependencies.

          (Z(:^

          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