3

Setup

  • I have a local installation of Qt located in my home directory: /home/user/Qt/... (from now on, devdir).

  • The Qt application that I'm trying to package installs the relevant Qt shared libraries to /usr/lib/myapplication (from now on, installdir).

  • My packaging process is currently set up like this:

    qmake > dh_make -s --createorig > debuild

Problem

I am trying to set RPATH in myapplication.pro to only link to libraries in installdir, but it is currently linking to both installdir and devdir.

I think it has to do with qmake creating dependencies to the installation libraries automatically. To try to stop it, I have run the build process with qmake -nodepend, but that hasn't stopped the link to devdir from happening.

How do I force qmake to link only to libraries in installdir?

Code

In myapplication.pro:

QMAKE_LFLAGS = -Wl,-rpath,/usr/lib/myapplication

The resulting link flags in the Makefile are:

LFLAGS = -Wl,-rpath,/usr/lib/myapplication -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-rpath,/home/user/Qt/5.3/gcc_64 -Wl,-rpath,/home/user/Qt/5.3/gcc_64/lib
Community
  • 1
  • 1
xpcoffee
  • 98
  • 1
  • 9
  • 1
    AFAIK, `RPATH` plays a role in determining which libraries to load at _runtime_. Perhaps it's `LIBPATH` (i.e. `-Linstalldir`) what you should touch...? – djsp Sep 17 '14 at 16:24
  • @Kalrish From what I understand, `LIBPATH` links to libraries while building, which is fine since _devdir_ is what I am using to build the project. Changing it would be OK if I only had static libraries. It is `RPATH` that determines where the application will look for shared libraries when executing on another system - so it is `RPATH` that I want to tell to only look in _installdir_. – xpcoffee Sep 18 '14 at 11:14
  • Then, it seems you need to set `RPATH` to both _devdir_ and _installdir_: the former for development, the later when shipping the program. See [this answer](http://unix.stackexchange.com/a/22999/54084). By the way, I believe that `RPATH` is deprecated and `RUNPATH` is preferred. – djsp Sep 18 '14 at 13:11
  • @Kalrish Yes, exactly what I was thinking. I am now at the shipping stage and would like to set `RUNPATH` so that it links only to _installdir_. It is currently linking to both, with the _devdir_ being linked by qmake automatically. I want to stop it from doing that, else I will have to constantly `chrpath` after building. Perhaps the original phrasing of the question wasn't clear? – xpcoffee Sep 18 '14 at 15:03
  • Although I don't know qmake, he right variables seem to be (`QMAKE_LIBDIR`)[http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#qmake-libdir] (library directories to search libraries in at link-time) and (`QMAKE_RPATHDIR`)[http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#qmake-rpathdir] (you are using Qt 4.8, right?). You could use `LD_LIBRARY_PATH` during development, setting `QMAKE_LIBDIR` to _devdir_ and `QMAKE_RPATHDIR` to _installdir_ (if it isn't in the default directories of your distribution by default; those settings, after all, are per-distro). – djsp Sep 18 '14 at 15:18

1 Answers1

0

The path to /home/user/Qt/5.3/gcc_64 can be removed by overwriting QMAKE_RPATHDIR. To suppress both paths the variable QMAKE_LFLAGS_RPATH should be empty as in Setting RPATH order in QMake

# rpath variables for unix
unix: {
    # suppress the default RPATH
    QMAKE_LFLAGS_RPATH =
    # add custom path
    QMAKE_LFLAGS = -Wl,-rpath,/usr/lib/myapplication
}
Community
  • 1
  • 1
Orest Hera
  • 6,706
  • 2
  • 21
  • 35