Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to command line build a proper dmg from a Qt app
Forum Updated to NodeBB v4.3 + New Features

How to command line build a proper dmg from a Qt app

Scheduled Pinned Locked Moved Solved Installation and Deployment
13 Posts 2 Posters 2.0k Views 1 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.
  • N Offline
    N Offline
    Nelson_Piquet
    wrote on last edited by
    #1

    I have Qt app lets say MyApp with a list of libraries it links to. Note that all libraries are linked statically linked. I have a master project file called MyMasterProjectFile.pro which loads all of these into QtCreator and yes the whole code builds well from QtCreator. I am using Qt 5.9.4 commercial version.

    I want to build my app+libraries command line into a dmg for MacOS High Sierra. I am doing this support CI builds on my build system.

    So, following is what my script does:

    // MyBuildScript.sh
    BuildDMGForMacOS() {
    
        /path/to/qmake MyMasterProjectFile.pro -spec macx-clang CONFIG+=Release CONFIG+=x86_64 $EXTRA_SETTINGS CONFIG+=qml_debug
        make -j2
    
        // Go inside the directory where my main app build folder is created
        /path/to/macdeployqt MyApp.app -verbose=2 -dmg
    }
    

    Issue:
    The dmg that is generated is not correct. But this is because if I double click and try to run the .app that is generated, I get the following error

    You can’t open the application “MyApp.app” because it is not
    supported on this type of Mac.

    Question:
    Looking at my script above, what am I missing in the method BuildDMGForMacOS to build a dmg for OSX?

    Note:
    Note that the dmg will be installed on OSX machines which wont have Qt installed on them.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      macdeployqt uses system tools to build the .dmg. These tools depending on the macOS version you have as well as your root file system will not generate the same .dmg content. There's now an option in the more recent versions of macdeployqt that allows to set the filesystem used to build the .dmg and uses a sensible default that is backward compatible.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        macdeployqt uses system tools to build the .dmg. These tools depending on the macOS version you have as well as your root file system will not generate the same .dmg content. There's now an option in the more recent versions of macdeployqt that allows to set the filesystem used to build the .dmg and uses a sensible default that is backward compatible.

        N Offline
        N Offline
        Nelson_Piquet
        wrote on last edited by
        #3

        @SGaist Is there an example I can get on how to use the new way in macdeployqt to get a proper dmg?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Just use a recent version of macdeployqt. The option is -fs.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          1
          • SGaistS SGaist

            Just use a recent version of macdeployqt. The option is -fs.

            N Offline
            N Offline
            Nelson_Piquet
            wrote on last edited by Nelson_Piquet
            #5

            @SGaist

            Looks like -fs did somthing with filestystem. I can see it logged the follwing extra thing. But its still the same issue

            Log: Image will use "HFS+"
            

            But, If I open MyApp/MyApp.app/Contents/MacOS/MyApp then it complains the following on console and gives up with a crash

            QQmlApplicationEngine failed to load component
            qrc:/qml/main.qml:1 module "QtQuick" is not installed
            qrc:/qml/main.qml:4 module "QtWebView" is not installed
            qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
            qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
            qrc:/qml/main.qml:1 module "QtQuick" is not installed
            qrc:/qml/main.qml:4 module "QtWebView" is not installed
            qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
            qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
            qrc:/qml/main.qml:1 module "QtQuick" is not installed
            qrc:/qml/main.qml:4 module "QtWebView" is not installed
            qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
            qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
            qrc:/qml/main.qml:1 module "QtQuick" is not installed
            qrc:/qml/main.qml:4 module "QtWebView" is not installed
            qrc:/qml/main.qml:2 module "QtQuick.Window" is not installed
            qrc:/qml/main.qml:3 module "QtQuick.Controls" is not installed
            
            [1]    57951 segmentation fault  /Volumes/MyApp/MyApp.app/Contents/MacOS/MyApp
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You did not use the qmldir option when running macdeployqt.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 1 Reply Last reply
              1
              • SGaistS SGaist

                You did not use the qmldir option when running macdeployqt.

                N Offline
                N Offline
                Nelson_Piquet
                wrote on last edited by Nelson_Piquet
                #7

                @SGaist
                Ah superb ! This made a difference. Now if I doubled clicked on the dmg and opened MyApp/MyApp.app/Contents/MacOS/MyApp that is inside it. It works and I am able to launch my app.

                Thanks a lot till here.

                But I am still curious why just double clicking on MyApp dies not work? Why do I have to run MyApp/MyApp.app/Contents/MacOS/MyApp instead of just MyApp ?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Do you have any error message ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    Do you have any error message ?

                    N Offline
                    N Offline
                    Nelson_Piquet
                    wrote on last edited by
                    #9

                    @SGaist
                    The error message says following with a pop up

                    You can’t open the application “MyApp.app” because it is not
                    supported on this type of Mac.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Are you using a pre-built version of Qt to build your application ?

                      By the way, why not use a more recent version of 5.9 ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      N 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Are you using a pre-built version of Qt to build your application ?

                        By the way, why not use a more recent version of 5.9 ?

                        N Offline
                        N Offline
                        Nelson_Piquet
                        wrote on last edited by
                        #11

                        @SGaist

                        Do you mean 5.9.6 ? I am using 5.9.4 but this error occurs even if I build with 5.11.2.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Can you show your .pro file ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          N 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Can you show your .pro file ?

                            N Offline
                            N Offline
                            Nelson_Piquet
                            wrote on last edited by
                            #13

                            @SGaist

                            My .pro file has so many things which is due to multiple stuff and it would not make much sense to share it here. But I have set QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12 and QML_IMPORT_PATH is set to nothing. Plus, following are some more settings I have in my .pro which might be relevant to this question

                            CONFIG += c++14
                            CONFIG -= bitcode
                            

                            I am marking this Topic as solved. Do let me know if have a suggestion on this last error.

                            1 Reply Last reply
                            0

                            • Login

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