Need help releasing a QT binary that uses QML with C++.
-
wrote on 1 Aug 2022, 10:39 last edited by
Hello, I wanted a C++ class that talks with QML.
In my.pro
file. I have the following declaration:CONFIG += qmltypes QML_IMPORT_NAME = banana.boutput QML_IMPORT_MAJOR_VERSION = 1 ... RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH =
The
main.cpp
consists of:qDebug("Welcome...\n"); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterType<Banana>("banana.boutput",1,0,"BOutput"); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();
In the
qml.qrc
->main.qml
I have:import QtQuick import QtQuick.Window import QtQuick.Controls import banana.boutput 1.0 Window { width: 100 height: 100 visible: true title: qsTr("Hello World") id: aWindow objectName: "awindows" color: "black" BOutput { id: bananachild } ComboBox { id: selectbananachild objectName: "bananaChildSelector" visible: true width: parent.width onCurrentIndexChanged: bananachild.onSelected(selectbananachild.currentIndex,selectbananachild.textAt(selectbananachild.currentIndex)) } Component.onCompleted: { bananachild.passParent(aWindow); aWindow.width = selectbananachild.width } }
And this all works. I hit compile and run inside QTCreator and it works fine. The QML and C++ are talking and all is good. Now I want to release it, and make it standalone.
I switch configuration to release and build. I copy the
.exe
over to a new folder.I then open a PowerShell terminal and navigate to the correct folder containing
windeployqt.exe
. In my case, it isQt\6.2.2\msvc2019_64\bin
.I run
.\windeployqt.exe locationOfBuildDirectory
When launching the released binary (
.exe
), it does nothing. Not even the "Welcome..." frommain.cpp
is outputted to the terminal. When using the tool dependency walker I get the following error:
?qml_register_types_banana_boutput@@YAXXZ
It runs and executes fine in QTCreator, what am I doing wrong?
-
Hello, I wanted a C++ class that talks with QML.
In my.pro
file. I have the following declaration:CONFIG += qmltypes QML_IMPORT_NAME = banana.boutput QML_IMPORT_MAJOR_VERSION = 1 ... RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH =
The
main.cpp
consists of:qDebug("Welcome...\n"); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterType<Banana>("banana.boutput",1,0,"BOutput"); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();
In the
qml.qrc
->main.qml
I have:import QtQuick import QtQuick.Window import QtQuick.Controls import banana.boutput 1.0 Window { width: 100 height: 100 visible: true title: qsTr("Hello World") id: aWindow objectName: "awindows" color: "black" BOutput { id: bananachild } ComboBox { id: selectbananachild objectName: "bananaChildSelector" visible: true width: parent.width onCurrentIndexChanged: bananachild.onSelected(selectbananachild.currentIndex,selectbananachild.textAt(selectbananachild.currentIndex)) } Component.onCompleted: { bananachild.passParent(aWindow); aWindow.width = selectbananachild.width } }
And this all works. I hit compile and run inside QTCreator and it works fine. The QML and C++ are talking and all is good. Now I want to release it, and make it standalone.
I switch configuration to release and build. I copy the
.exe
over to a new folder.I then open a PowerShell terminal and navigate to the correct folder containing
windeployqt.exe
. In my case, it isQt\6.2.2\msvc2019_64\bin
.I run
.\windeployqt.exe locationOfBuildDirectory
When launching the released binary (
.exe
), it does nothing. Not even the "Welcome..." frommain.cpp
is outputted to the terminal. When using the tool dependency walker I get the following error:
?qml_register_types_banana_boutput@@YAXXZ
It runs and executes fine in QTCreator, what am I doing wrong?
wrote on 2 Aug 2022, 14:34 last edited byAs it turns out, there was no issue. The application was doing exactly what it was told to do. The QML CPP implementation was looking for a JSON file. When in an event the application could not find the file, it should print something to console and exit. In this case, the pathing of the file was incorrect so it just exited without saying anything in the console. It has been resolved.
Thank you all for your help.
-
Hello, I wanted a C++ class that talks with QML.
In my.pro
file. I have the following declaration:CONFIG += qmltypes QML_IMPORT_NAME = banana.boutput QML_IMPORT_MAJOR_VERSION = 1 ... RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH =
The
main.cpp
consists of:qDebug("Welcome...\n"); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterType<Banana>("banana.boutput",1,0,"BOutput"); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();
In the
qml.qrc
->main.qml
I have:import QtQuick import QtQuick.Window import QtQuick.Controls import banana.boutput 1.0 Window { width: 100 height: 100 visible: true title: qsTr("Hello World") id: aWindow objectName: "awindows" color: "black" BOutput { id: bananachild } ComboBox { id: selectbananachild objectName: "bananaChildSelector" visible: true width: parent.width onCurrentIndexChanged: bananachild.onSelected(selectbananachild.currentIndex,selectbananachild.textAt(selectbananachild.currentIndex)) } Component.onCompleted: { bananachild.passParent(aWindow); aWindow.width = selectbananachild.width } }
And this all works. I hit compile and run inside QTCreator and it works fine. The QML and C++ are talking and all is good. Now I want to release it, and make it standalone.
I switch configuration to release and build. I copy the
.exe
over to a new folder.I then open a PowerShell terminal and navigate to the correct folder containing
windeployqt.exe
. In my case, it isQt\6.2.2\msvc2019_64\bin
.I run
.\windeployqt.exe locationOfBuildDirectory
When launching the released binary (
.exe
), it does nothing. Not even the "Welcome..." frommain.cpp
is outputted to the terminal. When using the tool dependency walker I get the following error:
?qml_register_types_banana_boutput@@YAXXZ
It runs and executes fine in QTCreator, what am I doing wrong?
@BlackApples said in Need help releasing a QT binary that uses QML with C++.:
windeployqt.exe
Hi
It should have picked up you are using QMLyou can try with
--qmldir pathtowherefilesare -
wrote on 1 Aug 2022, 10:57 last edited by
It should be noted there is no "boutput.qml" file anywhere. It is all declared in C++ as a
QML_ELEMENT
in the header file (.h
).I have tried that command. No success. The
qmldir
was pointed to the source directory -
It should be noted there is no "boutput.qml" file anywhere. It is all declared in C++ as a
QML_ELEMENT
in the header file (.h
).I have tried that command. No success. The
qmldir
was pointed to the source directoryLifetime Qt Championwrote on 1 Aug 2022, 11:04 last edited by mrjj 8 Jan 2022, 11:05@BlackApples
Did it copy any Qt dlls to the folder ?
the qmlimportscanner should look at the files but it sounds like some goes wrong.so you ran it like
windeployqt --qmldir c:\myApp\sources c:\build-myApp\myApp.exe (-ish paths different)
-
@BlackApples
Did it copy any Qt dlls to the folder ?
the qmlimportscanner should look at the files but it sounds like some goes wrong.so you ran it like
windeployqt --qmldir c:\myApp\sources c:\build-myApp\myApp.exe (-ish paths different)
wrote on 1 Aug 2022, 11:09 last edited bywindeployqt --qmldir c:\myApp\sources c:\build-myApp\myApp.exe (-ish paths different)
Yes, this is how I ran it.
I did not copy any additional Qt DLLs to the release folder. I assumed
windeployqt
would copy all the necessary DLLs I require. -
wrote on 1 Aug 2022, 11:20 last edited by
The file structure of the source folder is the following:
bananaproject.pro bananaproject.user.* main.cpp main.qml main.qrc banana.h banana.cpp
-
windeployqt --qmldir c:\myApp\sources c:\build-myApp\myApp.exe (-ish paths different)
Yes, this is how I ran it.
I did not copy any additional Qt DLLs to the release folder. I assumed
windeployqt
would copy all the necessary DLLs I require.@BlackApples
Hi
well, I have seen posts that sometimes windeployqt don't get it all.
But from your answer, it does copy the normal Qt DLLs but not the QML ones ?
(any DLLs with QML in name ?)Also the main.qml is added to the resource so its compiled in, right ?
I do wonder why it does not complain about missing DLLS when you click exe but just shows nothing.
Do you run the .exe on same PC or "clean" one ?
-
Hello, I wanted a C++ class that talks with QML.
In my.pro
file. I have the following declaration:CONFIG += qmltypes QML_IMPORT_NAME = banana.boutput QML_IMPORT_MAJOR_VERSION = 1 ... RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH =
The
main.cpp
consists of:qDebug("Welcome...\n"); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterType<Banana>("banana.boutput",1,0,"BOutput"); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();
In the
qml.qrc
->main.qml
I have:import QtQuick import QtQuick.Window import QtQuick.Controls import banana.boutput 1.0 Window { width: 100 height: 100 visible: true title: qsTr("Hello World") id: aWindow objectName: "awindows" color: "black" BOutput { id: bananachild } ComboBox { id: selectbananachild objectName: "bananaChildSelector" visible: true width: parent.width onCurrentIndexChanged: bananachild.onSelected(selectbananachild.currentIndex,selectbananachild.textAt(selectbananachild.currentIndex)) } Component.onCompleted: { bananachild.passParent(aWindow); aWindow.width = selectbananachild.width } }
And this all works. I hit compile and run inside QTCreator and it works fine. The QML and C++ are talking and all is good. Now I want to release it, and make it standalone.
I switch configuration to release and build. I copy the
.exe
over to a new folder.I then open a PowerShell terminal and navigate to the correct folder containing
windeployqt.exe
. In my case, it isQt\6.2.2\msvc2019_64\bin
.I run
.\windeployqt.exe locationOfBuildDirectory
When launching the released binary (
.exe
), it does nothing. Not even the "Welcome..." frommain.cpp
is outputted to the terminal. When using the tool dependency walker I get the following error:
?qml_register_types_banana_boutput@@YAXXZ
It runs and executes fine in QTCreator, what am I doing wrong?
@BlackApples first of, I would suggest executing the
qtenv2.bat
inside the folder, that also contains windeployqt.\windeployqt.exe locationOfBuildDirectory
that it wrong, instead of BuildDirectory, explicitly name the path and executable name , including extension.
do not forget to add -qmldir, like @mrjj said
and lastly, make sure, you're using the environment & windeployqt of the kit you used to compile/generate your executable
-
wrote on 1 Aug 2022, 11:48 last edited by
I have opened up a new PowerShell terminal. I have run
qtenv2.bat
andvcvarsall.bat amd64
.
I then run the following command in theQt\6.2.2\msvc2019_64\bin
:.\windeployqt --qmldir "c:\myApp\bananaproject" "c:\build-myApp\bananaproject.exe"
Then from the same terminal. I navigate to
c:\build-myApp\
. I run.\bananaproject.exe
.Same error. Nothing in the terminal. Application exits immediately.
-
I have opened up a new PowerShell terminal. I have run
qtenv2.bat
andvcvarsall.bat amd64
.
I then run the following command in theQt\6.2.2\msvc2019_64\bin
:.\windeployqt --qmldir "c:\myApp\bananaproject" "c:\build-myApp\bananaproject.exe"
Then from the same terminal. I navigate to
c:\build-myApp\
. I run.\bananaproject.exe
.Same error. Nothing in the terminal. Application exits immediately.
@BlackApples ok, as a test, give the qml path of the kit, instead of your project
--qmldir C:\Qt\Qt6.2.2\ msvc2019_64\qml
that will pull in and copy everything QML related. Its a brute force test, see if your app now starts.
-
wrote on 1 Aug 2022, 12:08 last edited by
Command executed:
.\windeployqt.exe -qmldir "C:\Qt\6.2.2\msvc2019_64\qml" "c:\build-myApp\bananaproject.exe"
Result when running
.\bananaproject.exe
:
Same error. Nothing in the terminal. -
Command executed:
.\windeployqt.exe -qmldir "C:\Qt\6.2.2\msvc2019_64\qml" "c:\build-myApp\bananaproject.exe"
Result when running
.\bananaproject.exe
:
Same error. Nothing in the terminal.@BlackApples interesting.
you said, the path is similar to what you posted, are there any special characters and or spaces in the path?
can you show the folder after the tool ran on it?
did you run the tool with --force argument? in cause there are residual files from a potentially wrong windployqt tool ?
what additional information do you get, when you run the tool vis a verbose level ?
--verbose <level> Verbose level (0-2). -
wrote on 1 Aug 2022, 12:54 last edited by
I have not run with the
windeployqt.exe
with the--force
argument. Should I try it?Build directory:
D3Dcompiler_47.dll Qt Qt5Compat Qt63DAnimation.dll Qt63DCore.dll Qt63DExtras.dll Qt63DInput.dll Qt63DLogic.dll Qt63DQuickScene2D.dll Qt63DRender.dll Qt6Concurrent.dll Qt6Core.dll Qt6Gui.dll Qt6LabsFolderListModel.dll Qt6Multimedia.dll Qt6MultimediaQuick.dl Qt6Network.dll Qt6OpenGL.dll Qt6Qml.dll Qt6QmlLocalStorage.dll Qt6QmlModels.dll Qt6QmlWorkerScript.dll Qt6QmlXmlListModel.dll Qt6Quick.dll Qt6Quick3D.dll Qt6Quick3DAssetImport.dll Qt6Quick3DAssetUtils.dll Qt6Quick3DEffects.dll Qt6Quick3DHelpers.dll Qt6Quick3DParticles.dll Qt6Quick3DRuntimeRender.dll Qt6Quick3DUtils.dll Qt6QuickControls2.dll Qt6QuickControls2Impl.dll Qt6QuickDialogs2.dll Qt6QuickDialogs2QuickImpl.dll Qt6QuickDialogs2Utils.dll Qt6QuickLayouts.dll Qt6QuickParticles.dll Qt6QuickShapes.dll Qt6QuickTemplates2.dll Qt6QuickTest.dll Qt6QuickTimeline.dll Qt6ShaderTools.dll Qt6Sql.dll Qt6StateMachine.dll Qt6StateMachineQml.dll Qt6Svg.dll Qt6Test.dll Qt6VirtualKeyboard.dll QtMultimedia QtQml QtQuick QtQuick3D QtTest bananaproject.exe geometryloaders iconengines imageformats networkinformation opengl32sw.dll platforminputcontexts platforms qmltooling renderers renderplugins sceneparsers sqldrivers tls translations vc_redist.x64.exe virtualkeyboard
I'm not sure what I'm doing wrong. I suspect it might be due to the application not being able to find the C++ implementation of the QML type
BOutput
. But I'm not an expert on this. I'm not too sure what it is doing. It does work and runs in QTCreator.The
--verbose 2
. There is no mention of an error. Additionally, there is no mention ofBOutput
- the CPP QML implementation.Command ran:
.\windeployqt.exe --qmldir "c:\myApp\bananaproject" "c:\build-myApp\bananaproject.exe" --verbose 2
-
wrote on 1 Aug 2022, 21:57 last edited by
I thought Qt creates a shell for each kit that gets installed. Then you open that shell to run commands related to that kit. I usually open the shell for the kit (it is in the start menu somewhere) then cd to the directory where I want to run the deploy program. The paths should be all correct for this.
-
I have not run with the
windeployqt.exe
with the--force
argument. Should I try it?Build directory:
D3Dcompiler_47.dll Qt Qt5Compat Qt63DAnimation.dll Qt63DCore.dll Qt63DExtras.dll Qt63DInput.dll Qt63DLogic.dll Qt63DQuickScene2D.dll Qt63DRender.dll Qt6Concurrent.dll Qt6Core.dll Qt6Gui.dll Qt6LabsFolderListModel.dll Qt6Multimedia.dll Qt6MultimediaQuick.dl Qt6Network.dll Qt6OpenGL.dll Qt6Qml.dll Qt6QmlLocalStorage.dll Qt6QmlModels.dll Qt6QmlWorkerScript.dll Qt6QmlXmlListModel.dll Qt6Quick.dll Qt6Quick3D.dll Qt6Quick3DAssetImport.dll Qt6Quick3DAssetUtils.dll Qt6Quick3DEffects.dll Qt6Quick3DHelpers.dll Qt6Quick3DParticles.dll Qt6Quick3DRuntimeRender.dll Qt6Quick3DUtils.dll Qt6QuickControls2.dll Qt6QuickControls2Impl.dll Qt6QuickDialogs2.dll Qt6QuickDialogs2QuickImpl.dll Qt6QuickDialogs2Utils.dll Qt6QuickLayouts.dll Qt6QuickParticles.dll Qt6QuickShapes.dll Qt6QuickTemplates2.dll Qt6QuickTest.dll Qt6QuickTimeline.dll Qt6ShaderTools.dll Qt6Sql.dll Qt6StateMachine.dll Qt6StateMachineQml.dll Qt6Svg.dll Qt6Test.dll Qt6VirtualKeyboard.dll QtMultimedia QtQml QtQuick QtQuick3D QtTest bananaproject.exe geometryloaders iconengines imageformats networkinformation opengl32sw.dll platforminputcontexts platforms qmltooling renderers renderplugins sceneparsers sqldrivers tls translations vc_redist.x64.exe virtualkeyboard
I'm not sure what I'm doing wrong. I suspect it might be due to the application not being able to find the C++ implementation of the QML type
BOutput
. But I'm not an expert on this. I'm not too sure what it is doing. It does work and runs in QTCreator.The
--verbose 2
. There is no mention of an error. Additionally, there is no mention ofBOutput
- the CPP QML implementation.Command ran:
.\windeployqt.exe --qmldir "c:\myApp\bananaproject" "c:\build-myApp\bananaproject.exe" --verbose 2
@BlackApples ok, Qt6, haven't really used that yet, at least not deployed.
From what I know, a Qt5 Application would miss, the
bearer
folder,QtQuick.2
(probably no longer needed for qt6),scenegraph
,styles
Like I said, not sure if a Qt6 application still requires those folders/dlls
I have not run with the windeployqt.exe with the --force argument. Should I try it
yes, in case you once used the wrong tool, from the wrong kit, the dlls won't be overwritten, since they are already "deployed"
-
Hello, I wanted a C++ class that talks with QML.
In my.pro
file. I have the following declaration:CONFIG += qmltypes QML_IMPORT_NAME = banana.boutput QML_IMPORT_MAJOR_VERSION = 1 ... RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH =
The
main.cpp
consists of:qDebug("Welcome...\n"); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; qmlRegisterType<Banana>("banana.boutput",1,0,"BOutput"); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();
In the
qml.qrc
->main.qml
I have:import QtQuick import QtQuick.Window import QtQuick.Controls import banana.boutput 1.0 Window { width: 100 height: 100 visible: true title: qsTr("Hello World") id: aWindow objectName: "awindows" color: "black" BOutput { id: bananachild } ComboBox { id: selectbananachild objectName: "bananaChildSelector" visible: true width: parent.width onCurrentIndexChanged: bananachild.onSelected(selectbananachild.currentIndex,selectbananachild.textAt(selectbananachild.currentIndex)) } Component.onCompleted: { bananachild.passParent(aWindow); aWindow.width = selectbananachild.width } }
And this all works. I hit compile and run inside QTCreator and it works fine. The QML and C++ are talking and all is good. Now I want to release it, and make it standalone.
I switch configuration to release and build. I copy the
.exe
over to a new folder.I then open a PowerShell terminal and navigate to the correct folder containing
windeployqt.exe
. In my case, it isQt\6.2.2\msvc2019_64\bin
.I run
.\windeployqt.exe locationOfBuildDirectory
When launching the released binary (
.exe
), it does nothing. Not even the "Welcome..." frommain.cpp
is outputted to the terminal. When using the tool dependency walker I get the following error:
?qml_register_types_banana_boutput@@YAXXZ
It runs and executes fine in QTCreator, what am I doing wrong?
wrote on 2 Aug 2022, 14:34 last edited byAs it turns out, there was no issue. The application was doing exactly what it was told to do. The QML CPP implementation was looking for a JSON file. When in an event the application could not find the file, it should print something to console and exit. In this case, the pathing of the file was incorrect so it just exited without saying anything in the console. It has been resolved.
Thank you all for your help.
1/16