83

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? Maybe 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...

I have found file libqxcb.so in the Qt SDK directory, but placing it in /usr/lib does not help.

Zanna
  • 70,465
locomotion
  • 931
  • 1
  • 7
  • 4
  • Very old question and I do not have the rep to answer, but for anyone browsing. I had this issue and tried many approaches... eventually my work around was to deploy via my existing Anaconda-navigator installation which worked seamlessly. – RichardBJ Dec 10 '20 at 13:18

17 Answers17

75

I had this error message when trying to run "Stellarium".

With strace I found that the missing file was libxcb-xinerama.so.0. I had to reinstall libxcb-xinerama0 to make it work:

sudo apt-get install --reinstall libxcb-xinerama0
wmeyer
  • 851
69

To any future readers who come across this - before you start (dangerously) messing around with symlinks to shared libraries, I strongly suggest that you run

export QT_DEBUG_PLUGINS=1

and then run your failing executable again in the Terminal. Read the actual error message thrown by QT, since none of the above solutions addressed the cause of this error in my case.

My output after turning on QT_DEBUG_PLUGINS was:

QFactoryLoader::QFactoryLoader() checking directory path "/opt/PostgreSQL/9.6/pgAdmin 4/bin/platforms" ...
loaded library "/opt/PostgreSQL/9.6/pgAdmin 4/plugins/platforms/libqxcb.so"
QLibraryPrivate::loadPlugin failed on "/opt/PostgreSQL/9.6/pgAdmin 4/plugins/platforms/libqxcb.so" : "Cannot load library /opt/PostgreSQL/9.6/pgAdmin 4/plugins/platforms/libqxcb.so: (/opt/PostgreSQL/9.6/lib/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16))"
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 (core dumped)

so I then googled the version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16)) error and found the solution to that, which solved the problem.

Casey L
  • 961
  • 4
    Not sure who down voted you. This gave me the traces needed to find the actual error relevant to my specific situation (in my case libc++.so was missing and had to be installed from libc++-dev". Thank you for posting this. – HBSKan Apr 10 '19 at 13:27
  • 2
    What do you do if the trace doesn't give you any error and then simply says seg fault? :/ – Firebug Feb 09 '20 at 21:17
  • 4
    Another env variable that might help is QT_PLUGIN_PATH, e.g. export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins – jlb Apr 09 '21 at 16:24
  • I was able to successfully run Viber after I followed this steps and install the missing lib files. – r2b2 May 12 '21 at 08:18
  • [centos7 here] i ran ldd on the .so file libqxcb.so and it revealed that there was about 5 missing .so files that were not found. so then i ran yum whatprovides *lib*/${filename} for each of the missing .so files and installed the required rpm file for each missing .so file that was not found. – Trevor Boyd Smith Feb 15 '22 at 20:20
25

Try to install libqt5x11extras5 package with command:
sudo apt-get install libqt5x11extras5

The name may be different. You can figure it out by searching:
sudo apt-cache search qt5 | grep 'X11 extras'

and u get the name of the package as result:

libqt5x11extras5 - Qt 5 X11 extras

Bonus_05
  • 351
16

The correct solution is running the following comand onto a terminal:

sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/

It creates the symbolic link it's missed.

Francesco
  • 285
  • 2
    This solved the problem for me. – Pratik Singhal Sep 02 '17 at 14:15
  • 3
    Why do you link the files in plugins/platforms to /usr/bin? The platforms directory contains shared libraries, /usr/bin is used for binary files. Shouldn't the contents of platforms go into /usr/lib? – Nathan F. Apr 20 '18 at 14:52
  • @NathanF. at least for my installation the Qt loader searches for platforms at /usr/bin/platforms (I don't know why). So this answer also worked for me: https://stackoverflow.com/a/25437758/2249798 – m13r Sep 23 '19 at 06:26
  • shouldn't the last part be the name of a symbolic link? (it just says /usr/bin/) – KansaiRobot Feb 01 '24 at 11:02
8

Running this solved it to me:

sudo apt-get --reinstall install libqt5dbus5 \
libqt5widgets5 libqt5network5 libqt5gui5 libqt5core5a \
libdouble-conversion1 libxcb-xinerama0
N0rbert
  • 99,918
FerranB
  • 190
5

For those who are still stuck after trying every other option out there in the internet, you can look into exact path from which this notorious libqxcb.so is being searched in, for opening/loading by the Qt App(VirtualBox-5.2.8 is the Qt app in my case), using the strace tool. In my case, since I was building VirtualBox-5.2.8 from its source, it was searching for libqxcb.so in the below location :
"...VirtualBox-5.2.8/out/linux.amd64/release/bin/platforms/" and not in the default library paths, Qt installation path, etc. So, none of the ldd checks, and other solutions worked. And also setting QT_DEBUG_PLUGINS=1 didn't produce any extra logs either.

Running strace on the the VirtualBox binary I built using Clang/LLVM on Ubuntu 17.10 x86_64:

...VirtualBox-5.2.8$ strace ./out/linux.amd64/release/bin/VirtualBox

.
.
.
access(".../VirtualBox-5.2.8/out/linux.amd64/release/bin/platforms/.", F_OK) = -1 ENOENT (No such file or directory)
write(2, "Qt FATAL: ", 10Qt FATAL: )              = 10
write(2, "This application failed to start"..., 154This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.) = 154
.
.
.

That was my hitting-the-nail-on-its-head moment, and I created the symlink from the installed Qt5.10.1's platforms directory mentioned below : "...Qt5.10.1/Tools/QtCreator/lib/Qt/plugins/platforms/" onto the searched path which is "...VirtualBox-5.2.8/out/linux.amd64/release/bin/". Thus, VirtualBox-5.2.8 built from source on Linux(Ubuntu 17.10 x86_64) using Clang/LLVM, finally launched successfully!

In fact, another interesting thing here is that, I have built VirtualBox-5.2.8 entirely using Clang/Clang++/LLVM on Ubuntu 17.10 x86_64 after substantial effort - for FreeBSD, there's already a port for building VirtualBox using clang but for Linux, it's heavily dependent on GCC as I saw and hence it took a lot of effort to get to this point to be able successfully build VirtualBox-5.2.8 from its source using Clang/Clang++/LLVM on Ubuntu 17.10 x86_64 for target Linux/AMD64(Ubuntu 17.10 x86_64) and successfully launch it after resolving other issues along with this notorious libqxcb.so one.

Cheers.

4

Run ldd on your application executable to see how it resolves library dependencies.

Also this is a must read to understand what essential libraries are needed in simple case of gui application:

http://qt-project.org/doc/qt-5/linux-deployment.html

Dorian
  • 270
4

In my ubuntu type:

sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/platforms

Can work

Videonauth
  • 33,355
  • 17
  • 105
  • 120
3

This is how solve few issues when I am running emulator on Ubuntu 18.04.

$ vim ~/.bashrc

Add the following lines at the end of file. I install my Android SDK at /opt/Android/Sdk

export ANDROID_HOME=/opt/Android/Sdk
export ANDROID_SDK_ROOT=/opt/Android/Sdk
export ANDROID_AVD_HOME=/home/<your name>/.android/avd
export LD_LIBRARY_PATH="/opt/Android/Sdk/emulator/lib64:$LD_LIBRARY_PATH"
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins
karel
  • 114,770
MZeng
  • 31
1

Platform: Kubuntu 18.

In my case, I did strace -f -s 1000 zoom -o zoom.trace, then studied zoom.trace. There was a lot of output. I searched for SIGABRT to narrow things down. The problem was that when Zoom launched /usr/bin/kde-open5, that process was hitting an internal assert right after trying to stat /usr/bin/platforms. On a whim, I did this:

 sudo ln -s /opt/zoom/platforms /usr/bin/platforms

and that got Zoom working. I realize that there are other issues with the KDE/QT installation that perhaps need to be fixed, but this was good enough for me to solve the problem for now.

Sasha Pachev
  • 111
  • 3
0

It seems there can be various different things missing behind this. In my case (Debian 9.7), QT_DEBUG_PLUGINS=1 did help to trace back the missing libraries, and

$ sudo apt-get install libxcb-render-util0 libxcb-image0 libxcb-keysyms1 libxcb-icccm4

solved the problem.

Antos
  • 3
0

Create file qt.conf in your project and add:

[Paths]
Plugins = /path/to/our/qt instalation/plugins

https://doc.qt.io/qt-5/qt-conf.html

Tomas
  • 1
0

The other answers here are very useful, but there is another potential cause for this behavior I've experienced which requires a completely different solution.

I was running Ubuntu 18.04 on VirtualBox 6.1.4, and after installing some proprietary applications my work uses, all Qt5 applications would fail to start. Like everyone else here, they printed an error message regarding their inability to load "xcb". After poking around for a while, I realized that "/usr/lib" was no longer being indexed by ldconfig. I'm surprised that this broke as few applications as it did, probably due to the fact that "/usr/lib/x86_64-linux-gnu" was still being indexed.

If you have the same problem, the fix is easy. Just add "/usr/lib/" to LD_LIBRARY_PATH using any one of these methods

David
  • 1
0

I faced the similar problem but with another application vkreplay as part of Vulkan.

You can try using strace to help see what's going on behind the scene (trace system calls and signals) in its attempt of loading shared library like following.

strace vkreplay -o vkcube_trace.vktrace -l 2

or

strace <your-command> <your-command-parameters>

for my case, I saw the following message dumped out

...
stat("/usr/lib/x86_64", 0x7ffc5f1c2aa0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64/libxcb-ewmh.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7ffc5f1c2aa0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/libxcb-ewmh.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
munmap(0x7fac93723000, 114202)          = 0
munmap(0x7fac92f9d000, 2109784)         = 0
munmap(0x7fac92f8b000, 69736)           = 0
...

Shared library in question is libxcb-ewmh.so.2 which is failed to load. Then I do apt search libxcb-ewmh, on my distro Ubuntu 19.10, I've found it's libxcb-ewmh2. Then you install it with sudo apt install libxcb-ewmh2.

At last, problem solves!

haxpor
  • 209
0

read closely, in case: QLibraryPrivate::loadPlugin failed on "/foo../venv/lib/python3.8/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /foo../venv/lib/python3.8/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)"

so it misses: https://packages.debian.org/sid/libxcb-util1

for debian not sid/bullseye backport it to your version eg stretch/buster, see https://backports.debian.org/Instructions/

droid192
  • 214
  • 2
  • 11
0

I had this error when starting Dropbox, and fixed it by deleting ~/.dropbox-dist, restarting Dropbox (command line: dropbox start -i) and allowing it to (re)install its proprietary daemon.

IpsRich
  • 117
-1

Copy plugins/platforms/libqxcb.so from your qt install to platforms/libqxcb.so in your application directory.

guntbert
  • 13,134
Adam
  • 21