I'm trying to get a dylib working in my OSX project.
Ive been reading a few samples, this one specifically: Xcode 4 adding dylib
But I still cannot get it to work.
Here are the steps I have performed:
- Copied the testing.1.dylib to my Xcode projects folder.
- Ran
sudo install_name_tool -id @executable_path/../Frameworks/testing.1.dylib testing.1.dylib
Ran:
otool -L testing.1.dylib
and received the following:testing.1.dylib:
@executable_path/../Frameworks/testing.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)Added the
testing.1.dylib
as a framework to the project. (Using the link bundle with library option).- At this point when I compile the testing1.dylib does not get copied into the .App/Framework as I expected, so I manually create the Framework path and copy the testing.1.dylib to it: a) mkdir -p testing.app/Contents/Frameworks b) cp testing.1.dylib testing.app/Contents/Frameworks
- In Xcode I update the
Runtime Search Paths
for BOTH the Target and the Project to be: @executable_path/../Frameworks.
Now I copy the testing.app to a separate freshly installed machine and attempt to run it. Which I get the following error:
dyld: Library not loaded: /user/local/lib/testing1.dylib Referenced from: /Users/me/testing.app/MacOS/./testing Reason: image not found
What am I missing?
Notes: When running install_name_tool, I need to use sudo or I get the following errors:
install_name_tool: can't open input file: testing.1.dylib for writing (Permission denied) install_name_tool: can't lseek to offset: 0 in file: testing.1.dylib for writing (Bad file descriptor) install_name_tool: can't write new headers in file: testing.1.dylib (Bad file descriptor) install_name_tool: can't close written on input file: testing.1.dylib (Bad file descriptor)