qrc:/mainQml.qml:4:1: module "QmlApp" is not installed
-
I am trying to build a AppImage for my Qt6 app. It uses internally QML. When I run it I get this error:
qrc:/mainQml.qml:4:1: module "QmlApp" is not installed
For what I understand, the QML runtime is not properly installed on the AppImage - which should be installed.
My CMake has
qt_add_qml_module
(this should deploy on install, no?).The script I use to create the AppImage is this:
cmake -S . -B cbuild -G Ninja -DCMAKE_BUILD_TYPE=Release cmake --build cbuild cmake --install cbuild --prefix=`pwd`/cbuild/AppDir/usr/ # failed experiment - this does not help cp -r $QT_DIR/qml `pwd`/cbuild/AppDir/usr/ cd cbuild wget --no-verbose "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" wget --no-verbose "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" chmod +x linuxdeploy*.AppImage export OUTPUT=PassSimpleQt-x86_64.AppImage export LD_LIBRARY_PATH=AppDir/usr/lib/:$LD_LIBRARY_PATH #export DEBUG=1 ./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin qt --output appimage
What am I missing?
Edit - relevant part of CMakeLists.txt:
qt_add_qml_module(pass-simple URI MainQml VERSION 1.0 SOURCES mainqmltype.h mainqmltype.cpp GpgIdManageType.h GpgIdManageType.cpp UiGuard.h UiGuard.cpp InputType/totp.h InputType/totp.cpp InputType/Base32.h InputType/Base32.cpp InputType/Clock.h InputType/Clock.cpp AppSettings.cpp AppSettings.h # hygen srcs QML_FILES mainQml.qml )
-
hi can you please copy/paste the full qt_add_qml_module from your CMakeLists.txt ?
-
@ankou29666 I edited the main question.
-
bumping this up,in case anyone knows the answer
-
@Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:
I edited the main question.
I don't see any module called
QmlApp
in your CMakeLists.txt -
@JKSH thanks, that oviously was a start..
I have inside this app, a sub directory which contains:qt6_add_qml_module(QmlApp URI QmlApp VERSION 1.0 SOURCES ...
OK - lets try and install it. I added at the end:
install(TARGETS QmlApp BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Still no go. I added to my build shell script:
cp -r QmlApp/*.qml `pwd`/cbuild/AppDir/usr/qml/QmlApp/
This still does not work. I looked at the documentation (https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html ) and it does not explain how/where to install QML modules.
I found this example, which (IMHO) shows that "I am doing the correct thing". So, I am kinda lost...
-
@Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:
OK - lets try and install it.
My suggestion: Don't install it manually.
And definitely don't
cp
the files manually. Rather, letqt_add_qml_module()
auto-generate the required files and put everything in the right place.- In your subdirectory's CMakeLists.txt, add the
STATIC
keyword toqt6_add_qml_module(QmlApp ...)
to generate a static library. - In your top-level CMakeLists.txt, add
add_subdirectory(QmlApp)
to build the static library together with your main app - In your top-level CMakeLists.txt, add
target_link_libraries(pass-simple PRIVATE QmlAppplugin)
to link to the static library.
This way, your QML module is embedded directly inside your application and gets auto-initialized.
P.S. What version of Qt are you using? The upcoming Qt 6.5 makes some changes to the default QML resource paths
I found this example, which (IMHO) shows that "I am doing the correct thing". So, I am kinda lost...
https://github.com/4rtzel/cmake-qml-plugin-example/blob/master/plugins/my/plugin/example/CMakeLists.txtThat example is very low-level, and is not very suitable for QML modules.
- In your subdirectory's CMakeLists.txt, add the
-
my top level cmake contains:
add_subdirectory(QmlApp) ... qt_add_qml_module(pass-simple URI MainQml VERSION 1.0 SOURCES mainqmltype.h mainqmltype.cpp GpgIdManageType.h GpgIdManageType.cpp UiGuard.h UiGuard.cpp InputType/totp.h InputType/totp.cpp InputType/Base32.h InputType/Base32.cpp InputType/Clock.h InputType/Clock.cpp AppSettings.cpp AppSettings.h QML_FILES mainQml.qml ) target_link_libraries(pass-simple PRIVATE Qt::Widgets Qt::QuickWidgets Qt6::Concurrent Qt6::LabsFolderListModel QmlApp EditYaml InputType DropdownWithList Datetime libpgpfactory yaml-cpp )
Then my
QmlApp/CMakeLists.txt
contains:qt6_add_qml_module(QmlApp URI QmlApp VERSION 1.0 STATIC SOURCES QmlAppType.h .... install(TARGETS QmlApp BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Still the same error on runtime. I can also see the same error when I run from the command line - without QtCreator.
-
Sorry for the delay.
@Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:
my top level cmake contains:
add_subdirectory(QmlApp) ... target_link_libraries(pass-simple PRIVATE ... QmlApp ... )
Link to
QmlAppplugin
instead ofQmlApp
Still the same error on runtime. I can also see the same error when I run from the command line - without QtCreator.
I asked for the version of Qt that you're using, but didn't get an answer. Anyway, see https://www.qt.io/blog/whats-new-for-qml-modules-in-6.5 -- Use Qt 6.5, add
qt_standard_project_setup(REQUIRES 6.5)
to your top-level CMakeLists.txt and callengine.loadFromModule()
instead ofengine.load()