Unsolved Static Qt 5.12.6 build on Ubuntu 18.04 - dreaded 'qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""' error
-
I'm trying to configure Qt as a static build so I can distribute my app more easily. I'm using Qt 5.12.6 commercial (built from the online installer "qt-unified-linux-x64-3.1.1-online.run") on Ubuntu 18.04 and QtCreator 4.11.
I've followed all of the various guides that I've found, as well as steps that others with the same problem did such as this ( https://forum.qt.io/topic/104197/error-running-statically-linked-application-could-not-find-the-qt-platform-plugin-xcb ).
I've installed all of the various package prerequisites that anyone has mentioned.
At the moment I'm just trying to build the included "analogclock" example, but I'm getting the dreaded error:
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.
I modified the example pro file to include:
QTPLUGIN.platforms = qminimal qxcb CONFIG -= import_plugins CONFIG += static
I've done loads of different build configurations of Qt itself but keep getting the same error. I've nuked the builds after each try, so I don't think its a problem with remnants from previous Qt builds. I must be missing something obvious.
This is the latest Qt build config that I'm using:
/home/will/Qt/5.12.6/Src/configure -commercial -confirm-license -static -release -ltcg -optimize-size -no-pch -qt-freetype -prefix "/home/will/Qt/5.12.6_Static" -skip webengine -nomake tools -nomake tests -nomake examples -no-sql-db2 -no-sql-oci -no-sql-tds -no-sql-sqlite2 -no-sql-odbc -no-sql-ibase -no-sql-psql -skip doc -skip webview -skip sensors -system-xcb -xcb-xlib -ltcg
I've configured QtCreator to build with the static qmake, and the resulting executable is about 5MB.
Q1. Do I need anything more in my code or .pro to tell it to not try and load plugins?
Q2. Do I need to add any libraries into the .pro file such as "libqxcb.a"?
Q3. Is my understanding correct that any required plugins will automatically be linked into the app and there is no need to include any kind of "plugins" folder?
-
So looking at the build output in QtCreator:
/home/will/Qt/5.12.6_Static/bin/qmake -o Makefile ../analogclock/analogclock.pro -spec linux-g++ CONFIG+=qtquickcompiler g++ -Wl,-O1 -Wl,--gc-sections -fPIC -o analogclock rasterwindow.o main.o moc_rasterwindow.o /home/will/Qt/qtbase/lib/libQt5Gui.a /usr/lib/x86_64-linux-gnu/libpng16.so /home/will/Qt/qtbase/lib/libqtharfbuzz.a /home/will/Qt/qtbase/lib/libQt5Core.a -lm /usr/lib/x86_64-linux-gnu/libz.so /home/will/Qt/qtbase/lib/libqtpcre2.a /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libGL.so -lpthread
It looks like it is still trying to build using libraries in "/home/will/Qt/qtbase/lib/" instead of "/home/will/Qt/5.12.6_Static/lib" - even though I have the static kit configured and selected in QtCreator.
Where is that configured?
EDIT: Files in "/home/will/Qt/qtbase/lib/" and "/home/will/Qt/5.12.6_Static/lib" are actually the same. So that's maybe not the issue.
-
@Will
I've run into the same issue. Can you, please, share any updates on this? -
@Skhms-E if I remember correctly it was fixed with the next Qt 5.12.7 update since it was a bug in Qt's build configuration. If you still get the bug then one of your build options. Below is part of my discussion with Qt support on this topic:
I looked in both files and didn't see an obvious failure the anything relating
to XCB. I've attached files.It doesn't list QPA modules that are not
going to be built and that doesn't seem to be listing XCB under there. In
config.log it looks like xcb libraries are found, but xkbcommon is not which
is one of the dependencies for it:looking for library xkbcommon
Trying source 0 (type pkgConfig) of library xkbcommon ...- /usr/bin/pkg-config --exists --silence-errors xkbcommon '>=' 0.5.0
pkg-config did not find package.
=> source produced no result.
Trying source 1 (type inline) of library xkbcommon ...
None of [libxkbcommon.so libxkbcommon.a] found in [] and global paths.
=> source produced no result.
test config.qtbase_gui.libraries.xkbcommon FAILED
You can probably just install libxkbcommon-dev package, then rerun configure
with -recheck-all as an additional option to force it to recheck all features. - /usr/bin/pkg-config --exists --silence-errors xkbcommon '>=' 0.5.0