19

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.

12 Answers 12

13

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.

  • 1
    This solved the problem for me. – Pratik Singhal Sep 2 '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: stackoverflow.com/a/25437758/2249798 – m13r Sep 23 at 6:26
9

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.

  • 2
    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 at 13:27
8

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
  • Wow, what a mess of a hunt this was trying various reinstalls. So grateful for this. – Hendy Sep 20 '18 at 1:01
6

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

3

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

2

In my ubuntu type:

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

Can work

  • 1
    This is not a good answer as it stands. Please edit to explain what exactly that command does. – Android Dev May 14 '16 at 0:23
  • Did not worked for me – Ratbert Apr 1 at 9:03
2

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.

1

Running this solved it to me:

sudo apt-get --reinstall install libqt5dbus5 \
libqt5widgets5 libqt5network5 libqt5gui5 libqt5core5a \
libdouble-conversion1 libxcb-xinerama0
0

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

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

-3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.