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:
QMAKE_LFLAGS_RPATH="-Wl,-rpath,/some/other/location"
# or remove it completely
QMAKE_LFLAGS_RPATH=
QMAKE_LFLAGS_RPATH="-Wl,-rpath,/some/other/location"
# or remove it completely
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:
$ man ld-linux.so
$ 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:
readelf -d programexe
...
readelf -d programexe
...
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.
Bookmarks