Linking a library statically



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


  • Moderators

    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



  • 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!


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.