OS X deployment problem (@rpath framework)
tsouni last edited by
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 ?
xtingray last edited by xtingray
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: *** [libtupiscenes.a] Error 1
So, I had to change my .pro files for the static libraries to become dynamic:
CONFIG += staticlib warn_on
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:
Pay 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:
Then I can run the app from console, typing:
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?
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
Qt Creator's rpath.pri shows a nice way to handle that.
xtingray last edited by xtingray
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! :)