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. Failing to macdeployqt
Forum Updated to NodeBB v4.3 + New Features

Failing to macdeployqt

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
13 Posts 3 Posters 1.0k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Did you already read the macOS deployment documentation ?

    It does not cover your exact use case (multiple executable in a single bundle) but it should give you already a basic understanding of the process.

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

    1 Reply Last reply
    1
    • PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by
      #5

      I had read it, but clearly didn't quite "get it" ...

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SimonSchroeder
        wrote on last edited by
        #6

        Well, an app is just one single program. Internally, the "app" is just a folder ending in .app. Inside it you'll find Contents/MacOS and that is where the single executable is located which is launched when opening the app (e.g. double clicking on the folder). If you have additional command line programs those usually are not apps (you'd have to type open mytool instead of ./mytool to run the command on the command line). If these are just called from the main app you can hide them inside the app folder (maybe Contents/Resources or create Contents/bin). Otherwise, Apple also has installer packages (.pkg) which extract several items (instead of just a single app folder) to their appropriate places. There would be an appropriate place for command line tools and the PATH environment variable should also be adapted to make them visible. But, I don't know how to create .pkgs.

        If you truly have multiple GUI programs, these should actually be separate apps.

        1 Reply Last reply
        3
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by
          #7

          Leaving aside multiple apps/executables, what do I need to change to get this to install?

          Right now I have now clue

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SimonSchroeder
            wrote on last edited by
            #8

            I am not using CMake myselft. Instead, our deploy step is just a simple script (this might help even if it is not the perfect solution):

            #!/bin/bash
            
            echo Delete old application folder.
            rm -rf MyApp.app
            
            echo Copy new application folder.
            cp -r ../release/MyApp.app ./
            install_name_tool -change /usr/local/lib/libomp.dylib @rpath/libomp.dylib MyApp.app/Contents/MacOS/MyApp # our app needs to change the path to this lib
            
            mkdir -p MyApp.app/Contents/Frameworks
            cp libomp.dylib MyApp.app/Contents/Frameworks/ # this is the extra lib we need
            
            echo Bundle Qt libs.
            /Users/Shared/Qt/5.13.2/clang_64/bin/macdeployqt MyApp.app
            
            echo Package examples.
            cp -r examples MyApp.app/Contents/Resources/
            
            echo Create dmg.
            rm MyApp.dmg
            bin/create-dmg --volname "MyApp Installer" --background ../src/rc/mac_dmg_background.png --window-pos 200 120 --window-size 598 465 --icon-size 80 --icon MyApp.app 150 330 --hide-extension "MyApp.app" --app-drop-link 450 330 MyApp.dmg MyApp.app
            
            echo Done.
            

            In this example we have to link with the OpenMP dynamic library. This is copied into the app folder. install_name_tool lets you change the path to dynamic libraries. You need to know the original path inside the executable in order to change it. You can look these up using otool on the executable (or was it the app?).

            In the end we are create a dmg image. This has a background image with an arrow pointing from the app icon to the applications folder (--app-drop-link) to suggest the user should just move the app over to the application folder for installation. The image looks something like this:
            2a6fca51-7336-414b-9584-9655b9ab4221-grafik.png
            (You also should have a file named mac_dmg_background@2x.png with double the resolution for Retina displays.)

            1 Reply Last reply
            1
            • SGaistS SGaist

              Hi,

              Looks like your are not setting the executable path correctly in the Apple case. You are just giving the bundle name rather than the path to the bundle.

              PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by Perdrix
              #9
              This post is deleted!
              1 Reply Last reply
              0
              • PerdrixP Offline
                PerdrixP Offline
                Perdrix
                wrote on last edited by
                #10
                This post is deleted!
                1 Reply Last reply
                0
                • PerdrixP Offline
                  PerdrixP Offline
                  Perdrix
                  wrote on last edited by
                  #11

                  Some progress but still having some problems:

                  if(NOT LINUX)
                      set (deploy_tool_options_arg "")
                      if(APPLE)
                          set(deploy_tool_options_arg "${deploy_tool_options_arg} -hardened-runtime")
                      elseif(WIN32)
                          set(deploy_tool_options_arg "${deploy_tool_options_arg} --pdb")
                      endif()
                  
                      # Generate a deployment script to be executed at install time
                      # App bundles on macOS have an .app suffix
                      if(APPLE)
                          set(executable_path "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:DeepSkyStacker>.app")
                      else()
                          message ("Target filename:"  $<TARGET_FILE_NAME:DeepSkyStacker>)
                          set(executable_path "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:DeepSkyStacker>")
                      endif()
                  
                      message ("executable_path: " ${executable_path})
                      message ("deploy tools options arg: " ${deploy_tool_options_arg})
                       qt_generate_deploy_script(
                           TARGET DeepSkyStacker
                           OUTPUT_SCRIPT deploy_script
                           CONTENT "
                       qt_deploy_runtime_dependencies(
                           EXECUTABLE \"${executable_path}\"
                           DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg}
                       )"
                       )
                  else()
                  qt_generate_deploy_app_script(
                      TARGET ${PROJECT_NAME}
                      OUTPUT_SCRIPT deploy_script
                      DEPLOY_TOOL_OPTIONS ${deploy_tool_options_arg}
                  )
                  endif()
                  install (SCRIPT ${deploy_script})
                  
                  install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION .)
                  

                  gets me this:

                  [226/227] Install the project...
                  -- Install configuration: "Debug"
                  -- Running Qt deploy tool for /Users/amonra/.vs/DSS/out/build/DeepSkyStacker/DeepSkyStacker.app in working directory '/Users/amonra/.vs/DSS/Darwin/arm64/Debug'
                  '/opt/Qt/6.8.2/macos/bin/macdeployqt' '/Users/amonra/.vs/DSS/out/build/DeepSkyStacker/DeepSkyStacker.app' '-appstore-compliant' '-always-overwrite' '-hardened-runtime'
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/MacOS
                  -- Installing: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/MacOS/DeepSkyStacker
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/PlugIns
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/PlugIns/platforminputcontexts
                  -- Installing: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/PlugIns/platforminputcontexts/libqtvirtualkeyboardplugin.dylib
                     :
                     :
                  -- Installing: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/Frameworks/QtQmlModels.framework/Versions/A/QtQmlModels
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/Frameworks/QtQmlModels.framework/Versions/A/Resources
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/Frameworks/QtQmlModels.framework/Versions/A/Resources/PrivacyInfo.xcprivacy
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/Frameworks/QtQmlModels.framework/Versions/A/Resources/Info.plist
                  -- Up-to-date: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/Frameworks/QtQmlModels.framework/Versions/Current
                  error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: for: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/MacOS/DeepSkyStacker (for architecture arm64) option "-add_rpath @executable_path/../Frameworks" would duplicate path, file already has LC_RPATH for: @executable_path/../Frameworks
                  error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: /opt/Qt/6.8.2/macos/lib found in: /Users/amonra/.vs/DSS/Darwin/arm64/Debug/./DeepSkyStacker.app/Contents/MacOS/DeepSkyStacker (for architecture arm64), required for specified option "-delete_rpath /opt/Qt/6.8.2/macos/lib"
                  

                  So, I think I'm almost there, but still missing something critical.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SimonSchroeder
                    wrote on last edited by
                    #12

                    Are you able to locate the generated deploy script? This would be really helpful to see the commands that are executed.

                    1 Reply Last reply
                    0
                    • PerdrixP Offline
                      PerdrixP Offline
                      Perdrix
                      wrote on last edited by Perdrix
                      #13

                      Found the file after quite a bit of digging.

                      include(/Users/amonra/.vs/DSS/out/build/.qt/QtDeploySupport.cmake)
                      include("${CMAKE_CURRENT_LIST_DIR}/DeepSkyStacker-plugins.cmake" OPTIONAL)
                      set(__QT_DEPLOY_I18N_CATALOGS "qtbase")
                      
                           qt_deploy_runtime_dependencies(
                               EXECUTABLE "/Users/amonra/.vs/DSS/out/build/DeepSkyStacker/DeepSkyStacker.app"
                               DEPLOY_TOOL_OPTIONS  -hardened-runtime
                           )
                      
                      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