Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problems with libqxcb.so



  • When I read the sentence "Deploy an Application for Linux is a Nightmare", I already guessed what to expect. But after 2 weeks of using Linux and encountering a problem as I describe it now is a really heavy house number. I was able to narrow down the problem. On the Linux systems I want to install the program on, the workaround will work. But as a long-time Windows user I want an installation where the user doesn't have to worry about anything.

    But first:
    OS: Linux Mint 19.3
    QT: 5.14.2

    The problem. My QT Application is using:

    libQt5Core.so.5
    libQt5Gui.so.5
    libQt5OpenGL.so.5
    libQt5SerialPort.so.5
    libQt5Svg.so.5
    libQt5Widgets.so.5

    The application should use local paths for the libs, so I wrote the following entries in the PRO file:

    unix:{

    suppress the default RPATH if you wish (No I don't wish)

    QMAKE_LFLAGS_RPATH =

    add your own with quoting gyrations to make sure $ORIGIN gets to the command line unexpanded

    QMAKE_LFLAGS += "-Wl,-rpath,'$$ORIGIN'"
    }

    After compiling, I checked the RUNPATH entries of the executable file with:

    readelf -d AirQualityMonitor | grep PATH

    The result

    0x000000000000001d (RUNPATH) Bibliothek runpath: [$ORIGIN:/usr/local/Qt-5.14.2/lib]

    is exactly what I want. Then I started to copy the libs from the Qt-5.14.2/lib directory to the application directory and rename them:

    libQt5Gui.so.5.14.2 -> libQt5Gui.so.5
    libQt5OpenGL.so.5.14.2 -> libQt5OpenGL.so.5
    libQt5SerialPort.so.5.14.2 -> libQt5SerialPort.so.5
    libQt5Svg.so.5.14.2 -> libQt5Svg.so.5
    libQt5Widgets.so.5.14.2 -> libQt5Widgets.so.5

    Up to this point I was able to call my program with:

    ./MyProc

    Everything works fine. Next Step is copy and rename:

    libQt5Core.so.5.14.2 -> libQt5Core.so.5

    Now I get a Error message that 'xcb' is present, but could not be loaded::

    Cannot load library /home/jadljlk/Workspace/AQIInstall/usr/local/bin/AQISuite/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: symbol _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)

    I set QT_DEBUG_PLUGINS=1 and type:

    ldd platforms/libqxcb.so

    The result revealed that the search path for "libQt5XcbQpa.so.5" was not the one to the "$ORIGIN" directory, but to:

    /usr/lib/x86_64-linux-gnu

    was diverted. In this directory also exists a file "libQt5XcbQpa.so.5" which contains a symbolic link to:

    libQt5XcbQpa.so.5.9.5

    contains. Since "libqxcb.so" (5.14.2) does not correlate with "libQt5XcbQpa.so.5" (5.9.5) there is a loading error. So I saved the original file and set the link to

    $ORIGIN/libQt5XcbQpa.so.5.14.2

    changed. This way I could start the program with ./MyProc and everything was running. Of course this is not a solution that you can offer to inexperienced users. How can I make the loader use the "$ORIGIN" path when loading "platforms/libqxcb.so" and not the path to the system ?

    ldd platforms/libqxcb.so



  • @TomBombadill said in Problems with libqxcb.so:

    I want an installation where the user doesn't have to worry about anything.

    What if you give it a try to the Qt Installer Framework (IFW)?

    It's the very same tool used by Qt itself for the offline installers...



  • I try the QT Installer Framework 3.2 last weekend. But the problems with the dependency Hell can't fix with this tool. But anyway. It's another installer system. And it works for Windows ans Linux. Until now I create my installation's with NSIS. Now I change to QT Installer Framework.

    The Problem is in QtCore. And today I search a solution in this module.



  • Hi, apart from setting the $ORIGIN on your main .exe file, you most likely need to "burn in" a new $ORIGIN setting on your shipping libqxcb.so as well.

    The libqxcb.so file for Qt 5.14.2 comes with the standard setting:
    RUNPATH=$ORIGIN/../../lib
    which works fine since the normal .dlls/.so files are in the ../../lib relative to the default ~/Qt/5.14.2/gcc_64/plugins/platforms subdirectory.

    However in your case you want to place the libqxcb.so file in a subdirectory platforms directly under the main .exe file and the .dlls/.so files.

    To change the $ORIGIN setting you can use a program called chrpath, i.e.
    sudo apt install chrpath
    then try

    chrpath -r \$ORIGIN/.. libqxcb.so
    

    (notice the backslash just before the $, to avoid bash eating the $)

    that should tell the ld program to look for libQt5XcbQpa.so.5 in the directory just above (verify that with ldd).



  • Cool. Thanks a lot.


Log in to reply