Yesterday I was reading a lot about deploying MacOSX applications, but I still have some doubts. I have been deploying Qt4 applications for MacOSX for the past few years using macdeployqt. Now, mi application uses a library that doesn't belong to the Qt framework: Poppler.
I have installed poppler-qt4 using Homebrew :
brew install poppler --with-qt4 --enable-xpdf-headers
After using macdeployqt, I know that I have to use install_name_tool to change the absolute paths by relative paths. Some of the dylibs have also dependencies:
MyApp.app/Contents/MacOS/MyApp: /usr/local/lib/libpoppler-qt4.4.dylib /usr/local/lib/libpoppler-qt4.4.dylib: /usr/local/Cellar/poppler/0.20.5/lib/libpoppler.28.dylib /usr/local/lib/libfontconfig.1.dylib /usr/local/lib/QtCore.framework/Versions/4/QtCore /usr/local/lib/QtGui.framework/Versions/4/QtGui /usr/local/lib/QtXml.framework/Versions/4/QtXml
After using macdeployqt I know that Qt frameworks have been copied inside the app bundle, How can I change /usr/local/lib/QtCore.framework/Versions/4/QtCore with a relative path using install_name_tool?
Are homebrew dylibs compiled using -headerpad_max_install_names?
Is there an automatic way to do this using brew?
What should I use with install_name_tool? @executable_path or @loader_path?
EDIT: It seems that macdeployqt is smart enough to deploy third party dylibs, poppler-qt4 and all its dependencies are copied to the Applicaciont.app/Frameworks folder, and install_name_tool is used automatically. BUT, now I am suffering this BUG : macdeployqt not copying plugins I suppose that the problem is "qt" on the name of poppler-qt4.4.
You can change by hand all the paths but it is error-prone, long and painful to do. What I suggest is to use a tool to do it for you: cpack included with cmake.
Anyways since 10.5 you should use: @loader_path. See Dylib.
For MacOS X the following code creates a bundle and copy properly homebrew dylib even with root permissions. However, you will have to check that every lib compiled with homebrew had the right parameters.
Usually, for deployement it is better to compile by hand the libs. I had some problems with homebrew libs (ffmpeg). But not Qt nor Boost :-).