4

I am on Ubuntu. When I type qtcreator on terminal, I get:

QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/bin/plugins/platforms/libqxcb.so"
Found metadata in lib /usr/bin/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331008
}


In /usr/bin/plugins/platforms/libqxcb.so:
  Plugin uses incompatible Qt library (5.13.0) [release]
"The plugin '/usr/bin/plugins/platforms/libqxcb.so' uses incompatible Qt library. (5.13.0) [release]" 
         not a plugin
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Aborted (core dumped)

I have been searching for an answer, but could not find an answer addressing my problem properly.

4

1 Answer 1

1

I've been having this error message when running an app built with Qt installed from sources (so this was due to the way I have installed Qt).

A quick

export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms

will transform the error above into qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms", so this is not a complete solution.

In my case the solution was to install xorg and xorg-dev - and other packages for that matter. Then reinstall Qt from sources.

These are all the packages that I have installed (on ubuntu 20.04):

sudo apt install libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev   \
                 libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev                \
                 libxcb-sync0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev                    \
                 libxcb-xinerama0-dev libxkbcommon-dev libxkbcommon-x11-dev libclang-dev                                            \
                 freeglut3-dev mesa-utils libdrm-dev libgles2-mesa-dev                                                              \
                 binutils g++ cmake g++ mesa-common-dev build-essential libglew-dev libglm-dev                                      \
                 make g++ pkg-config libgl1-mesa-dev libxcb1-dev libfontconfig1-dev libxkbcommon-x11-dev python libgtk-3-dev        \
                 build-essential default-jre openjdk-8-jdk-headless android-sdk android-sdk-platform-23 libc6-i386                  \
                 libdrm-dev libgles2-mesa-dev libzc-dev libxcb-sync-dev libsmartcols-dev libicecc-dev libpthread-workqueue-dev      \
                 libgstreamer1.0-dev libgcrypt20-dev libqt5gui5-gles qca-qt5-2-utils xorg xorg-dev

Mind you that default-jre openjdk-8-jdk-headless android-sdk android-sdk-platform-23 and possibly libc6-i386 too, are only required if you need to build android projects.

And this is how I installed Qt from sources:

export QT_VERSION=5.15.1
export QT5BINDIR=/usr/local/Qt-$QT_VERSION/bin
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/qt5/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms
export QT_QPA_FONTDIR=/usr/lib/x86_64-linux-gnu/qt5/lib/fonts

cd ~/Downloads/qt/qt-everywhere-src-$QT_VERSION/
sed -i 's/python /python3 /' qtdeclarative/qtdeclarative.pro \
           qtdeclarative/src/3rdparty/masm/masm.pri


./configure     -opensource -confirm-license    \
                -sysconfdir /etc/xdg            \
                -dbus-linked                    \
                -system-harfbuzz                \
                -nomake examples                \
                -no-rpath                       \
                -skip qtwebengine

make -j4
sudo make -j4 install
echo "Adding environment variables"
PATH=/usr/local/Qt-$QT_VERSION/bin:$PATH
export PATH

ldd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/*.so

A major source of documentation is Beyond Linux® From Scratch (System V Edition) - Qt-5.15.1 .

1
  • 1
    this didn't solve the problem for me qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/mona/venv/vision/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
    – Mona Jalal
    Jan 22, 2021 at 0:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .