Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Need help releasing a QT binary that uses QML with C++.
Forum Updated to NodeBB v4.3 + New Features

Need help releasing a QT binary that uses QML with C++.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
16 Posts 4 Posters 1.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B BlackApples

    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

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #4

    @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)
    
    B 1 Reply Last reply
    1
    • mrjjM mrjj

      @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)
      
      B Offline
      B Offline
      BlackApples
      wrote on last edited by
      #5

      @mrjj

      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.

      mrjjM 1 Reply Last reply
      1
      • B Offline
        B Offline
        BlackApples
        wrote on last edited by
        #6

        The file structure of the source folder is the following:

        bananaproject.pro
        bananaproject.user.*
        main.cpp
        main.qml
        main.qrc
        banana.h
        banana.cpp
        
        1 Reply Last reply
        0
        • B BlackApples

          @mrjj

          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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @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 ?

          1 Reply Last reply
          1
          • B BlackApples

            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 is Qt\6.2.2\msvc2019_64\bin.

            I run .\windeployqt.exe locationOfBuildDirectory

            When launching the released binary (.exe), it does nothing. Not even the "Welcome..." from main.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?

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #8

            @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


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            3
            • B Offline
              B Offline
              BlackApples
              wrote on last edited by
              #9

              I have opened up a new PowerShell terminal. I have run qtenv2.bat and vcvarsall.bat amd64.
              I then run the following command in the Qt\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.

              J.HilkJ 1 Reply Last reply
              0
              • B BlackApples

                I have opened up a new PowerShell terminal. I have run qtenv2.bat and vcvarsall.bat amd64.
                I then run the following command in the Qt\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.

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #10

                @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.


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                2
                • B Offline
                  B Offline
                  BlackApples
                  wrote on last edited by
                  #11

                  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.

                  J.HilkJ 1 Reply Last reply
                  0
                  • B BlackApples

                    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.

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #12

                    @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).


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    2
                    • B Offline
                      B Offline
                      BlackApples
                      wrote on last edited by
                      #13

                      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 of BOutput - the CPP QML implementation.

                      Command ran:
                      .\windeployqt.exe --qmldir "c:\myApp\bananaproject" "c:\build-myApp\bananaproject.exe" --verbose 2

                      J.HilkJ 1 Reply Last reply
                      0
                      • fcarneyF Offline
                        fcarneyF Offline
                        fcarney
                        wrote on last edited by
                        #14

                        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.

                        C++ is a perfectly valid school of magic.

                        1 Reply Last reply
                        1
                        • B BlackApples

                          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 of BOutput - the CPP QML implementation.

                          Command ran:
                          .\windeployqt.exe --qmldir "c:\myApp\bananaproject" "c:\build-myApp\bananaproject.exe" --verbose 2

                          J.HilkJ Offline
                          J.HilkJ Offline
                          J.Hilk
                          Moderators
                          wrote on last edited by
                          #15

                          @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"


                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                          Q: What's that?
                          A: It's blue light.
                          Q: What does it do?
                          A: It turns blue.

                          1 Reply Last reply
                          1
                          • B BlackApples

                            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 is Qt\6.2.2\msvc2019_64\bin.

                            I run .\windeployqt.exe locationOfBuildDirectory

                            When launching the released binary (.exe), it does nothing. Not even the "Welcome..." from main.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?

                            B Offline
                            B Offline
                            BlackApples
                            wrote on last edited by
                            #16

                            As 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 Reply Last reply
                            3

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved