11

I reinstalled my ubuntu 14.04 and Qt 5.4.1 and Qtcreator.

Qt 5.4.1 was built from source with "-opensource -nomake-test -nomake-example" configure options.

When I open an old project in QtCreator and build it everything's OK.

But when I run this project it shows:

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

Available platform plugins are: linuxfb, minimal, offscreen, xcb.

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

So I googled this problem and tried everything. I installed every packages (libxcb series) but nothing can help!

Somebody help me please...

I tried your methods.

When I run ldd command in platform directory, It shows: ldd libqxcb.so under platform$

You can see that nothing is missing. And actually I have made a softlink in the platform directory called libqxcb.so. There was no libqxcb.so in my platform directory before.

And when I run ldd command to my executable. it shows: executable shot

And you can see the error when I execute this file.

4
  • Did you read official documentation about deployment? What requests did you use in google? Commented Apr 2, 2015 at 6:51
  • 1
    I read this page and installed all the packages it mentioned but nothing happened. And I searched google using "This application failed to start because it could not find or load the Qt platform plugin 'xcb '" request. Commented Apr 2, 2015 at 8:45
  • 1
    Thanks, I tried this page. It's the same solution as the answer below. I use the ldd command but nothing happened. Commented Apr 2, 2015 at 11:24

12 Answers 12

24

For a similar issue, in my case I solved with:

export QT_PLUGIN_PATH=<qt base path>/plugins
5
  • 1
    Can't believe I had to search for so long to find this solution. How did you figure it out?
    – Haffi112
    Commented Jan 16, 2017 at 19:39
  • Actually read it in other similar questions in stackoverflow. Commented Jan 17, 2017 at 8:02
  • 8
    You can also set export QT_DEBUG_PLUGINS=1 to get some better detail on what's going on.
    – wardw
    Commented Dec 23, 2018 at 13:28
  • 1
    sorry to ask but where exacly are you adding that line? im compiling on my rpi3, do you addit to the cmake when you compile? or its in other place on the rpi3? Commented Apr 10, 2023 at 16:47
  • 1
    @lightshadown it is a system variable. I was setting it from linux shell. I don't know in rpi3, it depends on the operating system. Commented Apr 10, 2023 at 18:39
11

Try to go to the platforms folder of the Qt installation your program is using and run ldd libqxcb.so in a command prompt. Then check in the output if there are any missing dependencies. If the libqxcb.so is missing one of its dependencies this produces the output you mentioned.

You can also use the ldd command on your executable to check if there are any dependencies that can not be found.

Here is an example of what missing dependencies look like in the ldd output:

Example of <code>ldd</code> output

PS: the accepted answer of this question might also help you (creating a qt.conf file).

2
  • I go to the platform directory and run ldd libqxcb.so command. Every dependencies was found, nothing was missing. And I also run ldd my executable but there is not dependency on libqxcb.so. Very strange... Commented Apr 2, 2015 at 11:23
  • This is because libxcb.so is linked dynamically on startup, and ldd can only detects statically linked libraries. If there is no libxcb.so in the platform directory, either it wasn't built or it wasn't installed, check carefully the configure logs to see what happened. the softlink is 100% wrong. Commented Apr 2, 2015 at 14:37
5

I just stuck into a very similar issue for hours, also nothing is "not found" in ldd results on related executable, or libqxcb.so. finally I found it's the issue with the executable itself but not Qt. Tried QT_QPA_PLATFORM='' executable and it works :)

2
3

I got this exact error on linux xubuntu 18.04

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.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

First, defining this environment variable before starting qtcreator from the commandline causes more debug to be printed out:

export QT_DEBUG_PLUGINS=1

And then in the debug it said this when trying to start qtcreator from the commandline on xubuntu 18.04:

Cannot load library /home/myuser/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)

Note that it cannot find libxkbcommon-x11, so the fix was this:

sudo apt-get install libxkbcommon-x11-dev
export PATH=$PATH:~/Qt/Tools/QtCreator/bin

Now qtcreator starts.

1
  • 2
    In my case, libxcb-xinerama.so.0 was missing, so the fix was sudo apt install libxcb-xinerama0-dev Commented Aug 18, 2020 at 11:31
2

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

See the accompanying web page, scroll down to heading "Qt Plugins". See first paragraph.

libqxcb.so is required, even if you link the rest statically.

http://doc.qt.io/qt-5/linux-deployment.html#application-dependencies

Qt have probably written their source code software to work in the following way: Instead of allowing libqxcb.so to be loaded at startup automatically (using rpath's) they use a dlopen() function to load it, as part of their QPA function set, soon after main() begins.

So this completely disregards our attempt to include all the "xcb" functions statically.

If their dlopen() fails they just trot out their error message we all know and hate, and then call signal 6 to abort it (quite unnecessarily) instead of exiting normally.

1
  • 1
    Note, though, that you can override the path used by dlopen using a qt.conf file (I think). Commented Jun 7, 2016 at 0:40
1

for anyone that hasn't found the solution yet and desperately looking for an answer, this is a copy of what @wardw commented on the currently top rated answer, which helped me resolve my underlying issue.

export QT_DEBUG_PLUGINS=1

put this either in your run configuration or on the console before running your project and it will print more information about what is wrong.

0
1

This might be obvious, but I got this error while running a GUI from a (displayless) SSH session [ Why? I was developing an embedded app on a much larger screen, right next to the tiny touch screen it is intended for ].

Anyhow, in bash the following command targeted the app to its own screen:

export DISPLAY=':0.0'

Hope this helps someone.

0
1

In my case, i used Ubuntu 20.04 and this error stopped me from starting QT creator. i used the following command in a terminal:

export QT_DEBUG_PLUGINS=1

Then i ran the QT Creator from terminal again:

./qtcreator

then i had more detail error log:

Cannot load library /home/linhdh/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory) QLibraryPrivate::loadPlugin failed on "/home/linhdh/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/linhdh/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)" 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.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

so i ran the following command:

sudo apt-get install libxcb-xinerama0

after installing libxcb-xinerama0 i can run qtcreator normally. The error was fixed.

1

Install qtcreator 4.15.1 on Debian 10 have similar issue.

download qtcreator opensource

Show what library cause that error.

export QT_DEBUG_PLUGINS=1

Run /opt/qtcreator-4.15.1/bin/qtcreator

Search for corrupted lib ldd /opt/qtcreator-4.15.1/lib/Qt/plugins/platforms/libqxcb.so Find what library not link correctly.

Fix

Download library dependency and install it will fix.

sudo apt install ./libxcbutil1_0.4.0-1+b1_amd64.deb


source of answer

0
export QT_PLUGIN_PATH=<your qt installation path>/plugins/platforms

Similar to what mbjoe says, it really works!

0

I solved the issue with that command:

sudo ln -s /usr/lib/x86_64-linux-gnu/libxcb-util.so.0 /usr/lib/x86_64-linux-gnu/libxcb-util.so.1

My python: 3.7.5

Package: PyQt5

Os: Linux(Debian)

-1

Execute the command :

sudo ./app-name -platform linuxfb

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