Failed to run deployed qt app on another ubuntu machine: qt.qpa.plugin: could not load the qt platform plugin "xcb" in "" even though it was found
-
I built my Qt app on my own machine, deployed it by CQtDeployer and copied the deployed files to another machine. Both machines run the Ubuntu 22.04 system. However, my app cannot run on another machine. It shows error as follows (sorry it is a closed net machine so I cannot copy the text):
I have followed some posts and made sure libxcb-cursor0, libxcb-cursor-dev, libx11-xcb-dev, libx11-xcb1, libxcb-dri2-0, libxcb-dri3-0, libxcb-glx0, libxcb-icccm4, libxcb-image0, libxcb-image0-dev, libxcb-render0-dev, libxcb-render-util0-dev, libxcb-xinerama0, libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev, etc. are installed and can be found by dpkg or locate. I have set QT_QPA_PLATFORM=xcb and export QT_DEBUG_PLUGINS=1.
How to solve this problem? -
run:
ldd path/libqxcb.so
to check which libs are not installed
libqxcb.so can not be loaded because some of its dependencies are missing.The error messages show libxcb-cursor0 is not installed.
-
Also watch out for multiple installations of Qt on the target PC, I think I spot at least 2:
one at ~/software/suis/new/DistributionKit
one at /opt/QtTry to remove one of them.
Edit: if the Qt version in /opt/Qt is the default Ubuntu 22.04 Qt version 6.2.4 that could explain the error, since the version in ../DistributionKit is Qt 6.8.0. -
@hskoglund Hi, the qt under /opt/Qt is version 6.8.1 manually built from source and exists in LD_LIBRARY_PATH; do you mean by remove this path from LD_LIBRARY_PATH? I found that libQt6Gui.so.6, libQt6Core.so.6, etc. also exist in DistributionKit/lib
-
@Yihua-Liu Your application is trying to load a plugin from your deployment folder. This plugin is expecting a matching Qt version which, it seems you are saying is also in the deployment folder.
When you ran
ldd
against the plugin the Qt libraries found for linking were the set in/opt/Qt
.It is entirely possible that these are not the same Qt version. This would stop your plugin loading.
To use the Qt libraries bundled with your application over any Qt library present elsewhere you should look at the wrapper script in Create Application Package.