OS X deployment problem (@rpath framework)
-
Hi,
I'm trying to make OS X deployment of my desktop app. I have tried almost everything that I have found from google but none of the fixes seems to work. I'm using the os x deployment tool for sure.
The error what user gets when trying to start the app is:
"dyld: Library not loaded: @rpath/QtOpenGL.framework/Versions/5/QtOpenGL
Referenced from: /Volumes/:Users:jouni:koodaus:qt:gel build:gel/gel.app/Contents/MacOS/gel
Reason: image not found"
The .framework file is in the app bundle at Frameworks-directory (placed by the deployment tool). I can run the app from creator but if I try to run it directly (on my development machine) I get the same error.
Any ideas what should I try?
-
Hi and welcome to devnet,
What version of Qt are you using ?
Can you also post your .pro file content ?
-
I have exactly the same problem. This is my story:
Until Qt 5.3 I could compile and deploy my Qt app in Mac systems without any issue. My app had a set of plugins and a set of static libraries and the .dmg installer worked pretty well.
Now, since Qt 5.3 I started to get this compilation error from every one of my static libraries, specifically in OSX:
rm -f libtupiscenes.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib -s libtupiscenes.a error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: cant open file: libtupiscenes.a (No such file or directory) make[3]: *** [libtupiscenes.a] Error 1
So, I had to change my .pro files for the static libraries to become dynamic:
From this:CONFIG += staticlib warn_on
To this:
CONFIG += dll warn_on
With this change, the compilation process was clean once again, even with Qt 5.8. Now, the deployment process is another story.
Here is my original deployment script:
https://github.com/xtingray/tupi/blob/master/tools/build_mac_osx_app.shPay attention to the line 49 :
declare -a LIBS=('libtupigui.dylib' 'libtupistore.dylib' 'libtupi.dylib' \ 'libtupibase.dylib' 'libtupinet.dylib' 'libtupifwgui.dylib' 'libtupifwcore.dylib');
Now, that I have additional dynamic libraries after the compilation, I had to edit my script like this to add the new dylib files:
declare -a LIBS=('libtupigui.dylib' 'libtupistore.dylib' 'libtupi.dylib' \ 'libtupibase.dylib' 'libtupinet.dylib' 'libtupifwgui.dylib' 'libtupifwcore.dylib' 'libtupicolorpalette.1.dylib' 'libtupipaintarea.1.dylib' \ 'libtupianimation.1.dylib' 'libtupipen.1.dylib' 'libtupihelp.1.dylib' 'libtupimport.1.dylib' 'libtupiexport.1.dylib' 'libtupiexposure.1.dylib' \ 'libtupitimeline.1.dylib' 'libtupilibrary.1.dylib' 'libtupiscenes.1.dylib' 'libtupitwitter.1.dylib' 'libtupiplugincommon.1.dylib');
Supposedly, the deployment process finishes successfully but when I try either to run the .dmg installer or to run the binary from the terminal I got the same error message mentioned in this thread:
dyld: Library not loaded: @rpath/QtOpenGL.framework/Versions/5/QtOpenGL Referenced from: /Volumes/:Users:me:qt:Tupi build:Tupi/Tupi.app/Contents/MacOS/Tupi Reason: image not found
Now, this is the funny thing: If I set the variable DYLD_FRAMEWORK_PATH like this:
export DYLD_FRAMEWORK_PATH=/Users/me/Qt5.8.0/5.8/clang_64/lib
Then I can run the app from console, typing:
./Tupi.app/Contents/MacOS/Tupi
So, my question is: what I have to do or change to get my .dmg installer working as I did before with Qt 5.1?
Thanks!
P.S.: Looking inside of the .dmg package I built, I can see all the Qt libraries required by my app, including the QtOpenGL. So why the installer can't find them?
./Tupi.app/Contents/Frameworks/QtOpenGL.framework ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/QtOpenGL ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Resources ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Versions ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Versions/5 ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Versions/5/QtOpenGL ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Versions/5/Resources ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Versions/5/Resources/Info.plist ./Tupi.app/Contents/Frameworks/QtOpenGL.framework/Versions/Current
-
Thank you! Finally it worked for me, nevertheless I had to include the "Frameworks" path too:
QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../,-rpath,@executable_path/../Frameworks
I didn't have to do this before Qt 5.1.x versions, but it feels great to know how to fix it for newer versions. Thanks for the hint! :)