Results 1 to 2 of 2

Thread: Link to a specific version of shared library

  1. #1
    Join Date
    Jun 2016
    Posts
    9
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Link to a specific version of shared library

    Hi all

    I've some troubles with Qt Creator and library usage: In a program I need to include a uhd libary with version 3.9.1.
    I can create a static library (.a) or shared one (.so or .so.003.009 or .so.003) with the external build system.

    my really strange phenomenon is, that if I run the app from Qt Creator (debug or release), the correct library is loaded (version 3.9.1). But if I run the exact same file (in the created debug/release directory) from the terminal, the used library version is 3.10 (additional installed from gnu-radio). But I have really to need version 3.9.1 to communicate with an external hardware module.
    So how could I include the library correctly, that always version 3.9.1 is used?

    My current .pro file looks like this:
    Qt Code:
    1. QT += core
    2. QT -= gui
    3. TARGET = USRP_GUI
    4. CONFIG += console
    5. CONFIG -= app_bundle
    6. TEMPLATE = app
    7.  
    8. SOURCES += main.cpp \
    9. usrp_sdr.cpp
    10.  
    11. HEADERS += \
    12. usrp_sdr.h
    13.  
    14. # Include all Boost and UHD (v3.9.1) header files
    15. INCLUDEPATH += $$PWD/uhd/host/include/uhd
    16. INCLUDEPATH += /usr/include
    17.  
    18. # Include project files
    19. INCLUDEPATH += $$PWD/
    20. DEPENDPATH += $$PWD/
    21.  
    22. # Add boost header files and libraries
    23. INCLUDEPATH += /usr/local/include/boost
    24. LIBS += -L/usr/local/lib/ \
    25. -lboost_system \
    26. -lboost_filesystem \
    27. -lboost_serialization \
    28. -lboost_thread \
    29. -lboost_date_time \
    30. -lboost_regex \
    31. -lboost_program_options
    32.  
    33. unix:!macx: LIBS += -L$$PWD/uhd/host/build/lib/ -luhd
    34.  
    35. INCLUDEPATH += $$PWD/uhd/host/build/include
    36. DEPENDPATH += $$PWD/uhd/host/build/include
    To copy to clipboard, switch view to plain text mode 
    In a earlier version I hat also uhd 3.5.5 installed (from e linux distribution package). There were 3 different library versions installed without any problems and without uninstalling the older ones!? (linux is sometimes confusing)

    Does anyone have a solution or suggestion?
    Best regards
    P51D

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Link to a specific version of shared library

    For the runtime linker a library with the same major version is considered compatible and it uses the first one it finds.
    Of course there are bad libraries out there which do not keep compatibility as they should, so a very specific version is needed.

    If you have your version in your program directory, just set LD_LIBRARY_PATH in your start script to have that directory first, which will get it found before any system wide version.

    You can easily test that by setting the variable in a shell and using "ldd" on your executable.

    Cheers,
    _

Similar Threads

  1. How to link a shared library to app
    By kamlmish in forum Newbie
    Replies: 1
    Last Post: 25th December 2010, 20:57
  2. Can I link shared library in static build program?
    By berlinud in forum Installation and Deployment
    Replies: 1
    Last Post: 27th August 2010, 16:36
  3. how to use shared library
    By assismvla in forum Qt Programming
    Replies: 3
    Last Post: 25th September 2009, 21:29
  4. Problem with NCReport : can't link shared library !
    By QAmazigh in forum Qt Programming
    Replies: 4
    Last Post: 5th June 2009, 23:38
  5. Issues building 4.3.2 x11 shared version on Ubuntu 7.10
    By rickbsgu in forum Installation and Deployment
    Replies: 6
    Last Post: 11th December 2007, 01:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.