I wrote application for linux which uses Qt5.
But when I am trying to launch it on the linux without Qt SDK installed, the output in console is:
Failed to load platform plugin "xcb". Available platforms are:
How can I fix this? May be I need to copy some plugin file? When I use ubuntu with Qt5 installed, but I rename Qt directory, the same problem occurs. So, it uses some file from Qt directory...
UPDATE: when I create in the app dir "platforms" folder with the file libqxcb.so, the app still doesnot start, but the error message changes:
Failed to load platform plugin "xcb". Available platforms are:
xcb
How can this happen? How can platform plugin be available but can't be loaded?
So, I spent about a day trying to figure out what was the issue; tried all the proposed solutions, but none of that worked like installing xcb libs or exporting Qt plugins folder. The solution that suggested to use
QT_DEBUG_PLUGINS=1
to debug the issue didn't provide me a direct insight like in the answer - instead I was getting something about unresolved symbols within Qt5Core.That gave me a hint, though: what if it's trying to use different files from different Qt installations? On my machine I had standard version installed in
/home/username/Qt/
and some local builds within my project that I compiled by myself (I have other custom built kits as well in other locations). Whenever I tried to use any of the kits (installed by Qt maintenance tool or built by myself), I would get an "xcb error".The solution was simple: provide the Qt path through
CMAKE_PREFIX_PATH
and not thoughQt5_DIR
as I did, and it solved the problem. Example:cmake .. -DCMAKE_PREFIX_PATH=/home/username/Qt/5.11.1/gcc_64
Ubuntu 16.04 64bit. I got the problem for apparently no reasons. The night before I watched a movie on my VideoLan instance, that night I would like to watch another one with VideoLan. VLC just didn't want to run because of the error into the question. I google a bit and I found the solution it solved my problem: from now on, VLC is runnable just like before. The solution is this comand:
sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/
I am not able to explain what are its consequencies, but I know it creates some missing symbolic link.
I tried to start my binary, compiled with Qt 5.7, on Ubuntu 16.04 LTS where Qt 5.5 is preinstalled. Expectedly, it didn't work as is.
At first, I inspected the binary itself with
ldd
as was suggested here, and satisfied all "not found" dependencies. Then this notoriousThis application failed to start because it could not find or load the Qt platform plugin "xcb"
error was thrown in.What should be done on Linux to resolve this
At first, you should create
platforms
directory where your binary is, because it is the place where Qt looks for XCB library. Copylibqxcb.so
there. I wonder why authors of other answers didn't mention this.Then you may want to run your binary with
QT_DEBUG_PLUGINS=1
environment variable set to check what dependencies oflibqxcb.so
unsatisfied. (You may also useldd
for this as suggested in the accepted answer).The command output may look like this:
Note the failing
libQt5DBus.so.5
library. Copy it to your libraries path, in my case it was the same directory where my binary is (henceLD_LIBRARY_PATH=.
). Repeat this process until all dependencies are satisfied.P.S. thanks to the author of this answer for
QT_DEBUG_PLUGINS=1
.I link all Qt stuff statically to the generic Linux builds of my open source projects. It makes life a bit easier. You just need to build static versions of Qt libraries first. Of course this cannot be applied to closed source software due to licensing issues. The deployment of Qt5 apps on Linux is currently a bit problematic, because Ubuntu 12.04, for example, doesn't have Qt5 libraries in the package repositories.
Use ldd (man ldd) to show shared library dependencies. Running this on libqxcb.so
shows that xcb depends on libQt5DBus.so.5 in addition to libQt5Core.so.5 and libQt5Gui.so.5 (and many other system libs). Add libQt5DBus.so.5 to your collection of shared libs and you should be ready to move on.
I tried the main parts of each answer, to no avail. What finally fixed it for me was to export the following environment variables: