Reputation: 89
I am trying to deploy a Qt5 application for Linux (Debian) with dynamic linking. My app runs well on Ubuntu where all dependencies work well. My application package looks like this:
- application.exe
- qt.conf
- libicudata.so.54
- libicui18n.so.54
- libicuuc.so.54
- libQt5Core.so.5
- libQt5DBus.so.5
- libQt5XcbQpa.so.5
- libQt5Gui.so.5
- libQt5Widgets.so.5
- platforms / libqxcb.so
When I run it from the terminal on Debian I get this error message:
This application failed to start because it could not find or load the Qt platform plugin "xcb".
Available platform plugins are: xcb.
Reinstalling the application may fix this problem. Aborted
Then I ran ldd on libqxcb.so and saw that it I could not find the qt libs in the main folder. My application.exe can find all the qt libs by rpath in pro file so it is only the platform plugin that can not find the qt libs.
How can I set the path to Qt libs for the platform plugins?
Upvotes: 2
Views: 15112
Reputation: 9640
I had the same problem, both on Ubuntu and Debian, when running a Python application that relies on PyQt5
for its GUI:
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in ""
even though it was found. This application failed to start because
no Qt platform plugin could be initialized. Reinstalling the
application may fix this problem.
I got it easily fixed on Ubuntu. The fix on Debian was much harder. Below are my solutions.
DISCLAIMER
I'm not an experienced Linux user. Forgive me if the 'solutions' are more or less stitched together with duct tape.
On Ubuntu, I had it fixed quickly with this solution:
$ sudo apt-get install --reinstall libxcb-xinerama0
On Debian, it took me quite some time to find a fix. I first tried several things I found on this page: https://askubuntu.com/questions/308128/failed-to-load-platform-plugin-xcb-while-launching-qt5-app-on-linux-without
like:
$ sudo apt-get --reinstall install libxcb-util1
$ sudo apt-get --reinstall install libqt5x11extras5
$ sudo apt-get --reinstall install libqt5dbus5
$ sudo apt-get --reinstall install libqt5widgets5
$ sudo apt-get --reinstall install libqt5network5
$ sudo apt-get --reinstall install libqt5gui5
$ sudo apt-get --reinstall install libqt5core5a
$ sudo apt-get --reinstall install libdouble-conversion1
$ sudo apt-get --reinstall install libxcb-xinerama0
$ sudo apt-get --reinstall install '^libxcb.*-dev'
$ sudo apt-get --reinstall install '^libxcb-util.*-dev'
Nothing helped. I was wondering: could this have something to do with the fact that I was deploying a Python3.9
venv on my Debian machine? On Ubuntu, I was working in the native Python3.8
, so I guess all installations and re-installations worked just fine. But with a virtual environment, it might be not so straightforward?
My theory: I believe the virtual environment has its own Qt5 libs stored somewhere, and all the installations and reinstallations are happening on the "native" Qt5 libs - different from the Qt5 libs in the virtual environment.
Anyhow, I finally tried this:
$ ldd ~/Python-3.9.2/py3.9.2-env/lib/python3.9/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so | grep "not found"
libxcb-util.so.1 => not found
libxcb-util.so.1 => not found
This command figures out the missing dependencies for the given .so
file. I then downloaded libxcb-util.so.1
and libxcb-util.so.1.0.0
from this webpage:
which I found on this forum:
http://forums.debian.net/viewtopic.php?f=6&t=135672
I added both libxcb-util.so.1
and libxcb-util.so.1.0.0
to the ~/Python-3.9.2/py3.9.2-env/lib/python3.9/site-packages/PyQt5/Qt/plugins/platforms/
folder and then added this folder to my $LD_LIBRARY_PATH
env variable:
$ export LD_LIBRARY_PATH=/home/johan/Python-3.9.2/py3.9.2-env/lib/python3.9/site-packages/PyQt5/Qt/plugins/platforms:$LD_LIBRARY_PATH
Finally, the python application works!
Upvotes: 4
Reputation: 302
I got this error when I was trying to deploy my QT app as well. Try to find the plugins/platforms
folder in your Qt installation. For me it was ..Qt5.7.0/5.7/gcc_64/plugins/platforms
.
Copying the platforms
folder to the folder where my .so is stored worked for me. Oh! and don't forget to add LD_LIBRARY_PATH=/folder_With_.so_and_Platform
Upvotes: 0
Reputation: 89
I have solved it by starting the application with a startup script from http://doc.qt.io/qt-5/linux-deployment.html. But if anyone have any idea on how to solve it without using a script I would like to hear how. On the qt doc, same link as above, it says that it should be possible to do it with just rpath.
Upvotes: 0