Qt Quick with cmake fails on Linux
-
Hello,
I have a problem - when I build and run a Qt Quick app on Linux Mint 22 no window appears and some Qt metadata is printed to the console. On Windows 11 the same code works though.
The metadata:michal@Mint-VM:~/qt-test/build$ ./qt-test qt.core.plugin.factoryloader: checking directory path "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms" ... qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqvkkhrdisplay.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqvkkhrdisplay.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "vkkhrdisplay" ] }, "archlevel": 1, "className": "QVkKhrDisplayIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vkkhrdisplay") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqlinuxfb.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqlinuxfb.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "linuxfb" ] }, "archlevel": 1, "className": "QLinuxFbIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("linuxfb") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqxcb.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqxcb.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "xcb" ] }, "archlevel": 1, "className": "QXcbIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("xcb") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqeglfs.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqeglfs.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "eglfs" ] }, "archlevel": 1, "className": "QEglFSIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("eglfs") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqvnc.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqvnc.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "vnc" ] }, "archlevel": 1, "className": "QVncIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vnc") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqoffscreen.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqoffscreen.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "offscreen" ] }, "archlevel": 1, "className": "QOffscreenIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqwayland-generic.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqwayland-generic.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "wayland" ] }, "archlevel": 1, "className": "QWaylandIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("wayland") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqminimal.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqminimal.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimal" ] }, "archlevel": 1, "className": "QMinimalIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqwayland-egl.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqwayland-egl.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "wayland-egl" ] }, "archlevel": 1, "className": "QWaylandEglPlatformIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("wayland-egl") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqminimalegl.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqminimalegl.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimalegl" ] }, "archlevel": 1, "className": "QMinimalEglIntegrationPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimalegl") qt.core.plugin.factoryloader: checking directory path "/home/michal/qt-test/build/platforms" ... qt.core.library: "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqxcb.so" loaded library qt.core.library: "Xcursor" loaded library qt.core.plugin.factoryloader: checking directory path "/usr/lib/x86_64-linux-gnu/qt6/plugins/platformthemes" ... qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platformthemes/libqgtk3.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platformthemes/libqgtk3.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1", "MetaData": { "Keys": [ "gtk3" ] }, "archlevel": 1, "className": "QGtk3ThemePlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("gtk3") qt.core.plugin.factoryloader: checking directory path "/home/michal/qt-test/build/platformthemes" ... qt.core.library: "/usr/lib/x86_64-linux-gnu/qt6/plugins/platformthemes/libqgtk3.so" loaded library qt.core.plugin.factoryloader: checking directory path "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts" ... qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so, metadata= { "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1", "MetaData": { "Keys": [ "compose", "xim" ] }, "archlevel": 1, "className": "QComposePlatformInputContextPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("compose", "xim") qt.core.plugin.factoryloader: looking at "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so" qt.core.plugin.loader: Found metadata in lib /usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so, metadata= { "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1", "MetaData": { "Keys": [ "ibus" ] }, "archlevel": 1, "className": "QIbusPlatformInputContextPlugin", "debug": false, "version": 394240 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("ibus") qt.core.plugin.factoryloader: checking directory path "/home/michal/qt-test/build/platforminputcontexts" ... qt.core.library: "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" loaded library QQmlApplicationEngine failed to load component qrc:/qt/qml/qt_test/Main.qml: No such file or directory qt.core.plugin.factoryloader: checking directory path "/usr/lib/x86_64-linux-gnu/qt6/plugins/accessiblebridge" ... qt.core.plugin.factoryloader: checking directory path "/home/michal/qt-test/build/accessiblebridge" ... "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" unloaded library (faked) "/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms/libqxcb.so" unloaded library (faked) "/usr/lib/x86_64-linux-gnu/qt6/plugins/platformthemes/libqgtk3.so" unloaded library (faked) "Xcursor" unloaded library (faked)
Project files:
main.cpp#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(u"qrc:/qt/qml/qt_test/Main.qml"_qs); QObject::connect( &engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
Main.qml
import QtQuick Window { width: 640 height: 480 visible: true title: qsTr("Hello World") }
CMakeLists.txt
cmake_minimum_required(VERSION 3.16) project(qt-test VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.4 REQUIRED COMPONENTS Core Quick Qml) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(qt-test main.cpp ) set_property(TARGET qt-test PROPERTY WIN32_EXECUTABLE true) qt_add_qml_module(qt-test URI qt_test VERSION 1.0 QML_FILES Main.qml ) target_link_libraries(qt-test PRIVATE Qt6::Core Qt6::Quick Qt6::Qml ) install(TARGETS qt-test LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
I thought I might need to deploy it first so added code below to CMakeLists.txt but I got a cmake error when doing
cmake ..
.qt_generate_deploy_qml_app_script( TARGET qt-test OUTPUT_SCRIPT deploy_script ) install(SCRIPT ${deploy_script})
cmake Error:
... -- Found WrapOpenGL: TRUE -- Could NOT find XKB (missing: XKB_LIBRARY XKB_INCLUDE_DIR) (Required is at least version "0.5.0") -- Found WrapVulkanHeaders: /usr/include CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt6Qml/Qt6QmlMacros.cmake:2959 (message): Unexpected arguments: OUTPUT_SCRIPT;deploy_script Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/Qt6Qml/Qt6QmlMacros.cmake:3104 (qt6_generate_deploy_qml_app_script) CMakeLists.txt:32 (qt_generate_deploy_qml_app_script) -- Configuring incomplete, errors occurred!
Could someone tell me what is wrong?
-
@michal-19937 said in Qt Quick with cmake fails on Linux:
cmake_minimum_required(VERSION 3.16)
from https://doc.qt.io/qt-6/qt-generate-deploy-qml-app-script.html:
Warning: If you are using a CMake version lower than 3.19, make sure that you pass the MANUAL_FINALIZATION option to qt6_add_executable(), and then call qt6_finalize_target() before calling this function
-
@VRonin Sure
michal@Mint-VM:~/qt-test/build$ cmake .. -- The CXX compiler identification is GNU 13.2.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so -- Found WrapOpenGL: TRUE -- Could NOT find XKB (missing: XKB_LIBRARY XKB_INCLUDE_DIR) (Required is at least version "0.5.0") -- Found WrapVulkanHeaders: /usr/include CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt6Qml/Qt6QmlMacros.cmake:2959 (message): Unexpected arguments: OUTPUT_SCRIPT;deploy_script Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/Qt6Qml/Qt6QmlMacros.cmake:3104 (qt6_generate_deploy_qml_app_script) CMakeLists.txt:32 (qt_generate_deploy_qml_app_script) -- Configuring incomplete, errors occurred!
Full trace: https://drive.google.com/file/d/1R65jCE0caM0J23o6fQU5IC2MN-QALPri/view?usp=sharing
-
No, I don't have anything specific. I managed to get it to work on a fresh Mint, I'll install Qt on main Mint the same way I did on the fresh one and see if it works.
-
Alright, this nightmare finally ended, I got it to work. I believe the issues were caused by missing packages (qt6-declarative-dev and libxcb-cursor0), me forgetting to update CMAKE_PREFIX_PATH after reinstalling Qt and sometimes not removing hidden files from build directory when clearing. It got confusing with more than one problem. Thank you @VRonin for help.
Cheers -