How to compile qt with relative RUNPATH paths?



  • Hello.

    Prebuilt Qt 5.5.0 Linux libraries have RUNPATH set to $ORIGIN.
    What configure options are used in prebuilt version?
    What configure options should i use to achieve same thing in my own Qt builds?

    chrpath libQt5Widgets.so.5.5.0
    libQt5Widgets.so.5.5.0: RUNPATH=$ORIGIN

    chrpath libqxcb.so
    libqxcb.so: RUNPATH=$ORIGIN/../../lib


  • Moderators

    Hi @Mike_Blackman, and welcome to the Qt Dev Net!

    What configure options are used in prebuilt version?

    See http://code.qt.io/cgit/qtsdk/qtsdk.git/tree/packaging-tools/bld_config/configure_linux_opensource

    You might also be interested in this article, which talks about RPATH in built apps: http://www.tripleboot.org/?p=138



  • Thanks for your reply.

    @JKSH said:

    See http://code.qt.io/cgit/qtsdk/qtsdk.git/tree/packaging-tools/bld_config/configure_linux_opensource

    -opensource -confirm-license -debug-and-release -release -nomake tests -nomake examples -qt-zlib -qt-libjpeg -qt-libpng -qt-xcb -sysconfdir /etc/xdg -plugin-sql-mysql -plugin-sql-psql -plugin-sql-sqlite -openssl -dbus -no-libudev

    These configure options will produce libraries with default RUNPATH=/usr/local/Qt-5.5.0/lib.
    How to do i make RUNPATH relative?


  • Moderators

    @Mike_Blackman said:

    These configure options will produce libraries with default RUNPATH=/usr/local/Qt-5.5.0/lib.
    How to do i make RUNPATH relative?

    AFAIK, there are no configure options to set RUNPATH. Here are some ideas:

    • After building is complete, use chrpath to modify your libraries' RUNPATH
    • Modify the source code's *.pro files to pass the linker flag. Follow the tutorial I linked above -- it shows you how to make RPATH relative. Add --enable-new-dtags to set RUNPATH as well as RPATH
      • Note: I've never tried this myself on the Qt libraries, so I can't guarantee that this works. You might need to modify lots of different *.pro files in the source tree.


  • @JKSH said:

    AFAIK, there are no configure options to set RUNPATH.

    From configure help, additional options section:
    -R <string> ........ Add an explicit runtime library path to the Qt libraries.
    -l <string> ........ Add an explicit library.
    -no-rpath .......... Do not use the library install path as a runtime library path.
    -rpath ............. Link Qt libraries and executables using the library install path as a runtime library path. Equivalent to -R install_libpath.

    @JKSH said:

    Here are some ideas:

    • After building is complete, use chrpath to modify your libraries' RUNPATH

    There are many libraries with different relative paths to set. No way this is done manually.
    Are we missing any build steps?
    How Qt itself does it?

    How to compile "prebuilt Qt version" by yourself?


  • Moderators

    @Mike_Blackman said:

    From configure help, additional options section:
    -R <string> ........ Add an explicit runtime library path to the Qt libraries.
    -l <string> ........ Add an explicit library.
    -no-rpath .......... Do not use the library install path as a runtime library path.
    -rpath ............. Link Qt libraries and executables using the library install path as a runtime library path. Equivalent to -R install_libpath.

    These options are for RPATH. Do you want to set RPATH or RUNPATH?

    Also, could you describe why you want to set it? (If I'm not mistaken, these settings are important for the executable, but not the libraries).



  • @JKSH said:

    These options are for RPATH.

    I have tested these options. RUNPATH value were changing.

    @JKSH said:

    Do you want to set RPATH or RUNPATH?

    It's irrelevant in my case. But, if there is a way to set both of them, i want to know it.

    @JKSH said:

    Also, could you describe why you want to set it? (If I'm not mistaken, these settings are important for the executable, but not the libraries).

    Deployment problems. My application fails to load libqxcb.so plugin, because libqxcb.so plugin fails to locate Qt libraries. Prebuilt Qt solves this problem by using relative RUNPATH value within libqxcb.so.

    Best solution i've got so far:

    1. chrpath -r '$ORIGIN' ./*.so command within Qt lib directory
    2. chrpath -r '$ORIGIN/../../lib' ./* /*.so command within Qt plugins directory

    ./* /*.so - post bug, no space here

    Sorry, i am writing this away from my Ubuntu machine and English is not my native language.


  • Moderators

    @Mike_Blackman said:

    My application fails to load libqxcb.so plugin, because libqxcb.so plugin fails to locate Qt libraries. Prebuilt Qt solves this problem by using relative RUNPATH value within libqxcb.so.

    Sorry, I don't know what the prebuilt libraries did to the RPATH/RUNPATH. You can ask the Qt engineers in the Interest mailing list: http://lists.qt-project.org/mailman/listinfo/interest (Subscribe to the list first, then post there)


Log in to reply
 

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