3 Replies Latest reply: Jun 12, 2012 6:30 AM by Garvan Keeley RSS

    Plugins, deployment & Qt on a Mac

    Wayne C.

      I have a plug-in that links to the Qt framework (QtCore.framework and QtGui.framework) on Mac OS X 10.6.8 - XCode 3.2.6

       

      So I'm trying to deploy the plug-in onto a mac that doesn't already have the Qt framework installed, but with no success so far. This is what I've done:

       

      Added a Copy Files Build Phase to copy QtCore.framework & QtGui.framework to my plug-in bundle's Frameworks folder.

      Added a "Run Script Phase" to alter the install names of the frameworks which looks like this:

       

      install_name_tool -id @loader_path/../Frameworks/QtCore.framework/Versions/4/QtCore ${BUILD_DIR}"/"${WRAPPER_NAME}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore

      install_name_tool -id @loader_path/../Frameworks/QtGui.framework/Versions/4/QtGui ${BUILD_DIR}"/"${WRAPPER_NAME}/Contents/Frameworks/QtGui.framework/Versions/4/QtGui

       

      install_name_tool -change /usr/local/Trolltech/Qt-4.7.4/lib/QtCore.framework/Versions/4/QtCore @loader_path/../Frameworks/QtCore.framework/Versions/4/QtCore ${BUILD_DIR}"/"${WRAPPER_NAME}/Contents/MacOS/QtDeploymentTest

       

      install_name_tool -change /usr/local/Trolltech/Qt-4.7.4/lib/QtGui.framework/Versions/4/QtGui@loader_path/../Framewo rks/QtGui.framework/Version/4/QtGui ${BUILD_DIR}"/"${WRAPPER_NAME}/Contents/MacOS/QtDeploymentTest

       

      install_name_tool -change /usr/local/Trolltech/Qt-4.7.4/lib/QtCore.framework/Versions/4/QtCore @loader_path/../Frameworks/QtCore.framework/Versions/4/QtCore ${BUILD_DIR}"/"${WRAPPER_NAME}/Contents/Frameworks/QtGui.framework/Versions/4/QtGui

       

      But when Illustrator attempts to load the plug-in on the target mac, I'm getting this error:

       

      Error loading /Applications/Adobe Illustrator CS5.1/Plug-ins.localized/QtDeploymentTest.aip/Contents/MacOS/QtDeploymentTest:  dlopen(/Applications/Adobe Illustrator CS5.1/Plug-ins.localized/QtDeploymentTest.aip/Contents/MacOS/QtDeploymentTest, 262): Library not loaded: @loader_path/../Frameworks/QtCore.framework/QtCore

        Referenced from: /Applications/Adobe Illustrator CS5.1/Plug-ins.localized/QtDeploymentTest.aip/Contents/MacOS/../Frameworks/QtGui.framewor k/QtGui

        Reason: image not found

       

      Any ideas anyone? I was under the understanding that @loader_path should be the path to my plug-in's executable but ld still fails to load it.

        • 1. Re: Plugins, deployment & Qt on a Mac
          Garvan Keeley

          The problem appears to be QtGui trying to load QtCore, in this case QtGui will need a path to QtCore more along the lines of:

          @loader_path/../../../QtCore.framework/Versions/4/QtCore

          double check my '..' count

           

          AFAIK, the @loader_path is set to QtGui once that is being loaded. 

           

          You could also look at using rpath, there might be less figuring out what the relative paths are from each dylib to the next.

          • 2. Re: Plugins, deployment & Qt on a Mac
            Wayne C. Community Member

            Garvan, you are a legend, thank you!

            AFAIK, the @loader_path is set to QtGui once that is being loaded.

             

            ^ This was the vital piece of info I've been missing. I knew that QtGui loaded QtCore but I wasn't aware that @loader_path was reset once a library had been loaded.

             

            I wasn't aware of @rpath until I read an article today stating that it should be used in favour of @loader_path, I'll be looking into that next!

            FYI, your '..' count was spot on

             

            Much appreciated as always, thanks again.

            • 3. Re: Plugins, deployment & Qt on a Mac
              Garvan Keeley Community Member

              No prob, happy to help anyone brave enough to use Qt with AI