"Failed to load platform plugin "xcb" " while launching qt5 app on linux without qt installed
Asked Answered
H

21

130

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?

Hefty answered 14/6, 2013 at 10:22 Comment(5)
Just to clarify, are the Qt libraries actually installed?Cabral
If Qt library is installed, the program works normally. If it is not installed, or the qt sdk dir is not found, the program does not work.Hefty
Make sure you also copy libQt5Gui.so.5 as wellJariah
For those coming here from Eve Online launcher: Use eveonline.sh, not eveonline - the launcher has all libs bundled with special versions.Shroud
My issues was solved by using python 3.8 and not 3.7 for anyone who's using pythonKnow
B
66

Use ldd (man ldd) to show shared library dependencies. Running this on libqxcb.so

.../platforms$ ldd 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.

Beaux answered 30/8, 2013 at 12:5 Comment(8)
Thank you! This is exactly what the problem was. libQt5DBus.so.5 should be listed in the documentation along with core and gui.Gesellschaft
In my case sudo apt-get install libx11-xcb1 fixed the problem. But your recommendation of using ldd was what pointed me to the correct library to install. Thanks!Teledu
In my case I also had to add libQt5XcbQpa.so.5 to the lib folder.Repellent
If you still have this problem after going through ldd, try finding the plugins/platforms directory within your Qt installation. Try to copy this entire directory to the same place as your binary or shared library file. If that works, you may set LD_LIBRARY_PATH (hacky) or, as mentioned in the answer by @bossbarber, QT_QPA_PLATFORM_PLUGIN_PATH.Domineering
In my case i didnt have the the /usr/bin/platforms dir created. Solved with: sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/Jaquiss
I was trying to deploy my QT app. Copying the platform folder to my .so folder worked for me. Oh! and don't forget to add LD_LIBRARY_PATH=/folderWith_.so_and_PlatformCabrera
I wish there were simple instructions so someone who didn't have an electronic engineering degree could get a simple linux server usable and running. I can't understand a word of any of this. I have a stock install of Ubuntu, I haven't customized anything, and after 3 days of work and googling I don't have a working desktop. Why is it so hard to get running?Deathful
I found the libQt5DBus.so.5 in the "Qt5/lib" folder. What do you mean by "add this to your collection of shared libs"? Which folder am I supposed to paste this file in? New to this, thanks a lot.Grandstand
A
60

As was posted earlier, you need to make sure you install the platform plugins when you deploy your application. Depending on how you want to deploy things, there are two methods to tell your application where the platform plugins (e.g. platforms/plugins/libqxcb.so) are at runtime which may work for you.

The first is to export the path to the directory through the QT_QPA_PLATFORM_PLUGIN_PATH variable.

QT_QPA_PLATFORM_PLUGIN_PATH=path/to/plugins ./my_qt_app

or

export QT_QPA_PLATFORM_PLUGIN_PATH=path/to/plugins
./my_qt_app

The other option, which I prefer is to create a qt.conf file in the same directory as your executable. The contents of which would be:

[Paths]
Plugins=/path/to/plugins

More information regarding this can be found here and at using qt.conf

Aaron answered 22/8, 2014 at 0:3 Comment(4)
Wow! Thanks so much! Didn't know about qt.conf, it should on the first page of deployment FAQZouave
in my case for some reason the path inside the qt.conf (Plugins=plugins) was not recognized. I ended up supplying an empty qt.conf file, which let the global (hard coded) paths be overwritten with the qt.conf-defaults, in my case the plugins-Subfolder in the app-directory.Novotny
We were wondering why LD_LIBRARY_PATH wasn't working, but QT_QPA_PLATFORM_PLUGIN_PATH did the trick. Super-thanks.Pork
2nd or 3rd time I come to this answer and it helps every time.Knuckleduster
R
32

I tried to start my binary, compiled with Qt 5.7, on Ubuntu 16.04 LTS where Qt 5.5 is preinstalled. It didn't work.

At first, I inspected the binary itself with ldd as was suggested here, and satisfied all "not found" dependencies. Then this notorious This application failed to start because it could not find or load the Qt platform plugin "xcb" error was thrown.

How to resolve this in Linux

Firstly you should create platforms directory where your binary is, because it is the place where Qt looks for XCB library. Copy libqxcb.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 which dependencies of libqxcb.so are not satisfied. (You may also use ldd for this as suggested in the accepted answer).

The command output may look like this:

me@xerus:/media/sf_Qt/Package$ LD_LIBRARY_PATH=. QT_DEBUG_PLUGINS=1 ./Binary
QFactoryLoader::QFactoryLoader() checking directory path "/media/sf_Qt/Package/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/media/sf_Qt/Package/platforms/libqxcb.so"
Found metadata in lib /media/sf_Qt/Package/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 329472
}


Got keys from plugin meta data ("xcb")
loaded library "/media/sf_Qt/Package/platforms/libqxcb.so"
QLibraryPrivate::loadPlugin failed on "/media/sf_Qt/Package/platforms/libqxcb.so" : "Cannot load library /media/sf_Qt/Package/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5DBus.so.5: version `Qt_5' not found (required by ./libQt5XcbQpa.so.5))"
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: xcb.

Reinstalling the application may fix this problem.
Aborted (core dumped)

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 (hence LD_LIBRARY_PATH=.). Repeat this process until all dependencies are satisfied.

P.S. thanks to the author of this answer for QT_DEBUG_PLUGINS=1.

Raffinate answered 27/9, 2016 at 12:58 Comment(3)
I found that while there were unspecified dependencies on libQt5xcbQpa.so.5 and libQtDBus.so.5 I still needed to add the platforms folder as you indicates. THAT combination made it work.Bonilla
Can anyone point me to "For Dummies" explanation of how to fix this error? I have no idea what any of this stuff means, I need step-by-step instructions for how to resolve this in linux.Deathful
@JohnSmith it's better if you tell us what exactly doesn't make any sense to you. Then we will try to elaborate.Raffinate
P
16

I tried the main parts of each answer, to no avail. What finally fixed it for me was to export the following environment variables:

LD_LIBRARY_PATH=/usr/local/lib:~/Qt/5.9.1/gcc_64/lib
QT_QPA_PLATFORM_PLUGIN_PATH=~/Qt/5.9.1/gcc_64/plugins/ 
Perfumer answered 14/8, 2017 at 16:33 Comment(2)
This worked for me on Ubuntu 17.10 (but having this problem since 16.04!) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/. Unfortunately it only fixed my VLC, not Virtualbox that has the same error...Parkinson
Worked in Ubuntu 18.04 to get texworks 0.6.2 up and running.Riparian
S
11

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.

Sebiferous answered 19/10, 2016 at 19:4 Comment(2)
Do not use -f --force flag until U really know what are you doing. This may cause other problems.Knuckleduster
This was what solved it for me with Ubuntu 18.04 (the application having the problem is Rescue Time.) Just leave off the -f flag in case you already have a directory there.Transonic
E
7

Since version 5, Qt uses a platform abstraction system (QPA) to abstract from the underlying platform.

The implementation for each platform is provided by plugins. For X11 it is the XCB plugin. See Qt for X11 requirements for more information about the dependencies.

Entebbe answered 14/6, 2013 at 10:47 Comment(5)
So, I just need to install all packages from the list of dependencies? And this will work? Also I found the file libqxcb.so in the QT SDK dir, but placing it in the usr/lib directory does not resolved my problem.Hefty
The page Deploying an Application on X11 Platforms should contain all the information you need.Entebbe
I installed all packages mentioned on that page, but it didn't help. I found the information, that the platform plugins must be in the directory of the executable in the folder "platforms". I put there xcb plugin, now the erroe changed: "Failed to load platform plugin "xcb". Available platforms are: xcb "Hefty
@Entebbe It is dead again :(Clingy
@user89 not for me. temporary problem maybe?Entebbe
T
7

There might be many causes to this problem. The key is to use

export QT_DEBUG_PLUGINS=1

before you run your Qt application. Then, inspect the output, which will point you to the direction of the error. In my case it was:

Cannot load library /opt/nao/plugins/platforms/libqxcb.so: (/opt/nao/bin/../lib/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16))

But that is solved in different threads. See for instance https://mcmap.net/q/175385/-lib-x86_64-linux-gnu-libz-so-1-version-zlib_1-2-9-39-not-found.

Trotman answered 4/2, 2019 at 9:56 Comment(1)
:facepalm: OMG, this same advice AGAIN. No, this does not provide any useful information, just a much more verbose version of the same exact error. No hints or clues for anything else to look at. Nothing missing, nothing "cannot load" that I didn't already know.Deathful
A
6

Probably this information will help. I was on Ubuntu 18.04 and when I tried to install Krita, using the ppa method, I got this error:

This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".

Available platform plugins are: linuxfb, minimal, minimalegl, offscreen, wayland-egl, wayland, xcb.

Reinstalling the application may fix this problem.

Aborted

I tried all the solutions that I found in this thread and other webs without any success.

Finally, I found a post where the author mention that is possible to activate the debugging tool of qt5 using this simple command:

export QT_DEBUG_PLUGINS=1

After adding this command I run again krita I got the same error, however this time I knew the cause of that error.

libxcb-xinerama.so.0: cannot open shared object file: No such file or directory.

This error prevents to the "xcb" to load properly. So, the solution will be install the `libxcb-xinerama.so.0" right? However, when I run the command:

sudo apt install libxcb-xinerama

The lib was already installed. Now what Teo? Well, then I used an old trick :) Yeah, that one --reinstall

sudo apt install --reinstall libxcb-xinerama

TLDR: This last command solved my problem.

Arnulfoarny answered 12/7, 2018 at 3:52 Comment(0)
D
3

I ran into a very similar problem with the same error message. First, debug some by turning on the Qt Debug printer with the command line command:

export QT_DEBUG_PLUGINS=1

and rerun the application. For me this revealed the following:

"Cannot load library /home/.../miniconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"

"Cannot load library /home/.../miniconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"

Indeed, I was missing libxkbcommon-x11.so.0 and libxkbcommon-x11.so.0. Next, check your architecture using dpkg from the linux command line. (For me, the command "arch" gave a different and unhelpful result)

dpkg --print-architecture #result for me: amd64

I then googled "libxkbcommon-x11.so.0 ubuntu 18.04 amd64", and likewise for libxkbcommon-x11.so.0, which yields those packages on packages.ubuntu.com. That told me, in retrospect unsurprisingly, I'm missing packages called libxkbcommon-x11-0 and libxkbcommon0, and that installing those packages will include the needed files, but the dev versions will not. Then the solution:

sudo apt-get update

sudo apt-get install libxkbcommon0

sudo apt-get install libxkbcommon-x11-0

Dealer answered 12/3, 2020 at 21:37 Comment(0)
G
2

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 though Qt5_DIR as I did, and it solved the problem. Example:

cmake .. -DCMAKE_PREFIX_PATH=/home/username/Qt/5.11.1/gcc_64

Golub answered 18/7, 2018 at 16:37 Comment(1)
Oh, man, what is it with the Linux world, where every single solution on the web provides unexpected errors instead of working? Ever? Three days now of trying to get a working desktop on a stock install of Ubuntu. No, for those coming here from Google: this solution does not work any better than anything else on this page. I'm beginning to think Linux doesn't actually work at all.Deathful
D
2

Folks trying to get this started on Ubuntu 20.04 please try to run this and see if this solves the problem. This worked for me

sudo apt-get update -y
sudo apt-get install -y libxcb-xinerama0
Dullish answered 24/11, 2021 at 12:40 Comment(0)
H
1

I faced the same problem when after installing Viber. It had all required qt libraries in /opt/viber/plugins/. I checked dependencies of /opt/viber/plugins/platforms/libqxcb.so and found missing dependencies. They were libxcb-render.so.0, libxcb-image.so.0, libxcb-icccm.so.4, libxcb-xkb.so.1 So I resolved my issue by installing missing packages with this libraries:

apt-get install libxcb-xkb1 libxcb-icccm4 libxcb-image0 libxcb-render-util0

Houck answered 17/6, 2016 at 19:38 Comment(2)
I had a problem launching Tizen Emulator. This helped. Thanks.Newsboy
ancient answer, but very helpful. On WSL2, for a similar issue, I also had to install libxcb-keysyms1, libxcb-randr0, libxcb-xinerama0, libxkbcommon-x11-0, libgl1Chacma
K
1

I like the solution with qt.conf.

Put qt.conf near to the executable with next lines:

[Paths]
Prefix = /path/to/qtbase

And it works like a charm :^)

For a working example:

[Paths]
Prefix = /home/user/SDKS/Qt/5.6.2/5.6/gcc_64/

The documentation on this is here: https://doc.qt.io/qt-5/qt-conf.html

Knuckleduster answered 7/2, 2018 at 8:44 Comment(2)
And I "put qt.conf near to the executable" how, exactly?Deathful
Create file with presented content. cd path/to/executable; vim qt.conf, paste. Save and exit.Knuckleduster
N
1

In my case missing header files were the reason libxcb was not built by Qt. Installing them according to https://wiki.qt.io/Building_Qt_5_from_Git#Linux.2FX11 resolved the issue:

yum install libxcb libxcb-devel xcb-util xcb-util-devel mesa-libGL-devel libxkbcommon-devel
Nonmoral answered 4/4, 2020 at 16:24 Comment(1)
Yeah I think I had a similar problem. Even compiled qt from source but did not notice that the xcb-toolchain was not sane on my system so the qt-xcb parts did not get installed.Peacoat
E
1

All you need to do is

pip uninstall PyQt5 

and

conda install pyqt 

Most of the problem of pyqt can be fixed by this simplest solution.

Emalia answered 15/10, 2021 at 0:35 Comment(1)
Many years on, I'm running at Qt GUI app under WSL (i.e. Ubuntu 20.04 on Windows) and this fixed that exact error for me!Aten
M
0

In my case, I needed to deploy two Qt apps on an Ubuntu virtualbox guest. One was command-line ("app"), the other GUI_based ("app_GUI").

I used "ldd app" to find out what the required libs are, and copied them to the Ubuntu guest. While the command-line executable "app" worked ok, the GUI-based executable crashed, giving the "Failed to load platform plugin "xcb" error. I checked ldd for libxcb.so, but this too had no missing dependencies.

The problem seemed to be that while I did copy all the right libraries I accidentally had copied also libraries that were already present at the guest system.. meaning that (a) they were unnecessary to copy them in the first place and (b) worse, copying them produced incompatibilities between the install libraries. Worse still, they were undetectable by ldd like I said..

The solution? Make sure that you copy libraries shown as missing by ldd and absolutely no extra libraries.

Morgun answered 28/11, 2015 at 14:25 Comment(1)
And, I fix my problem using this advice, how?Deathful
S
0

I solved the issue through this https://github.com/NVlabs/instant-ngp/discussions/300

pip uninstall opencv-python
pip install opencv-python-headless

This seems to have been a problem with the cv2 Python package and how it loops in Qt

Spitsbergen answered 9/11, 2022 at 6:14 Comment(0)
E
-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.

Electrobiology answered 26/12, 2013 at 0:21 Comment(0)
P
-1

I had this problem, and on a hunch I removed the Qt Configs from my environment. I.e.,

rm -rf ~/.config/Qt*

Then I started qtcreator and it reconfigured itself with the existing state of the machine. It no longer remembered where my projects were, but that just meant I had to browse to them "for the first time" again.

But more importantly it built itself a coherent set of library paths, so I could rebuild and run my project executables again without the xcb or qxcb libraries going missing.

Pegmatite answered 31/8, 2018 at 15:41 Comment(2)
Qtcreator gives the same exact error I'm trying to solve. Of course. Because if I found so much as one working solution to any Linux problem on the web, it's wouldn't be Linux. Sorry, this is just incredibly frustrating, an entire SE page of wild goose chases without a single usable solution on it to simply get a desktop panel running on a stock Ubuntu install without errors. I am becoming very dubious that Linux actually works right at all.Deathful
This did not help in my case.Paquette
O
-1

I faced the same situation, but on a Ubuntu 20.04 VM.

TL;DR: Check file permissions.

What I did:

  • I copied the Qt libs required to /usr/local/lib/x86_64-linux-gnu/ and added it to LD_LIBRARY_PATH
  • I copied the platforms folder from Qt to my application directory and added it to QT_PLUGIN_PATH
  • I ran ldd on the executable and in the offending libqxcb.so (ldd libqxcb.so), and it complains about some dependencies although ldconfig listed them as found.
        linux-vdso.so.1 (0x00007ffee19af000)
    libQt5XcbQpa.so.5 => not found
    libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f7cb18fb000)
    libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f7cb183c000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7cb1820000)
    libQt5Gui.so.5 => /usr/local/lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f7cb0fd4000)
    libQt5DBus.so.5 => not found
  • I used export QT_DEBUG_PLUGINS=1 for further info. It complains about missing files, although they are there.

What I found:

  • For some reason, when copying to the VM through the shared folder the files permissions were not the correct ones.
  • Thus, I ran: sudo chmod 775 * on the libs and voilà.
Ossicle answered 27/9, 2022 at 22:54 Comment(0)
D
-5

sudo ln -sf /usr/lib/...."adapt-it"..../qt5/plugins/platforms/ /usr/bin/

It creates the symbolic link it's missed. Good for QT ! Good for VLC !!

Delanadelancey answered 2/2, 2017 at 2:6 Comment(3)
explain your answerInfrequent
Doesn't work. Because nothing works. This page is 100% wrong, not even a single one of the "solutions" here works.Deathful
@JohnSmith judging by the amount of upvotes on answers, some of them certainly work for some people. Unfortunately nothing works for you and I can understand your frustration. But if nothing works, try to do your own research and submit an answer that worked in your case. I mean, come on, you are using the platform for 5 years and have only 6 answers? I'd humbly suggest to give back to the community instead of complaining. We're here to help each other.Raffinate

© 2022 - 2024 — McMap. All rights reserved.