Results 1 to 5 of 5

Thread: Changing Qt Lib Paths

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    122
    Thanks
    62
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Changing Qt Lib Paths

    I performed the standard Qt SDK install, and my binaries produced show
    paths to the Qt libraries as /home/QtSDK/etc as revealed by entering the
    ldd command under Linux. I am building within Qt Creator using a .pro
    file.

    As a result, check paths under Linux when building an RPM detects this
    absolute path as an error.

    For my distribution, I intend to use an RPM to copy two Qt libraries
    to /usr/lib64 on a target machine that will not have Qt installed on
    it.

    While I have changed the LD_LIBRARY_PATH within the QtCreator IDE,
    the binaries produced continue to reference my local home SDK install.

    I would like this to be the /usr/lib64 pathname where the libraries
    are also stored.

    Is there a easy way to do this?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Changing Qt Lib Paths

    The easy way to do it is to build using the system Qt4 (i.e. use its qmake) rather than the one you are using so that the RPATH/RUNPATH are "correct".

    Alternatively, you can force the RPATH using your PRO file:
    Qt Code:
    1. QMAKE_LFLAGS_RPATH="-Wl,-rpath,/some/other/location"
    2. # or remove it completely
    3. QMAKE_LFLAGS_RPATH=
    To copy to clipboard, switch view to plain text mode 
    You can also remove the RPATH/RUNPATH from your executable after it is built using a utility "chrpath".

    The rules for locating libraries can can be found in:
    Qt Code:
    1. $ man ld-linux.so
    To copy to clipboard, switch view to plain text mode 
    but you have to temper that with some "What actually happens" information: http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/

    Qt builds executable with both DT_RPATH and DT_RUNPATH set by default. You can see that in the output of:
    Qt Code:
    1. readelf -d programexe
    2. ...
    To copy to clipboard, switch view to plain text mode 
    With both set, RPATH is ignored and the dynamic linker will use LD_LIBRARY_PATH, the RUNPATH embedded locations, and the system locations in that order. This is why the Creating the Application Package instructions use a script to ensure that a set of Qt libraries bundled in the application directory are found first. If you don't use LD_LIBRARY_PATH and the RUNPATH does not exist on the target then the system locations will be searched for needed libraries.

    You should be aware to writing your application Qt libraries into system location may cripple any system Qt installed on that machine. If you want a system Qt on the machine I suggest you use the system's package manager to install a compatible version.
    Last edited by ChrisW67; 20th April 2012 at 00:24.

Similar Threads

  1. Relative paths in Qt
    By drmath in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 16:50
  2. Replies: 2
    Last Post: 10th August 2009, 09:45
  3. include paths
    By altec in forum Installation and Deployment
    Replies: 0
    Last Post: 8th August 2008, 11:59
  4. Problems with paths
    By zorro68 in forum Installation and Deployment
    Replies: 1
    Last Post: 13th July 2008, 11:20
  5. How to set paths?
    By hoborg in forum Installation and Deployment
    Replies: 11
    Last Post: 24th February 2006, 19:08

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.