Application I was developing links with a custom dylib, I developed. All was working well while running through XCode. However on deployment, the application would not launch. On investigation, I realized that OSX was unable to find a dylib, Hence the application failed to launch.
I was faced with the problem of the OSX not knowing where to find the dylibs required by my application in deployment environment.
otool and install_name_tool came to my rescue.As per Apple documentation
otool- Object file displaying tool.install_name_tool- change dynamic shared library install names.
First I wanted see to all the library install names in my application. In simple terms paths of all the libraries my application is linked with.
On terminal in cd into my app package Contents/Macos.
% otool -L myAppUnixBinayThe output listed all the library install names.
libmycustom.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)My application linked against libmycustom.dylib, it failed to load it since no proper path was provided.
Now I used install_name_tool to set the right path to the dylib.
% install_name_tool -change libmycustom.dylib @executable_path/../Frameworks/libmycustom.dylib myAppUnixBinayThe above line tell the OSX to find the library in /Contents/Frameworks of the application package.
Now when I ran the application all worked well.
I automated this process by adding a runscript to XCode target that runs post build process.
Read Part 2 of the post
Read Part 3 of the post
No comments:
Post a Comment