Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Thomas Harte

macrumors 6502
Original poster
Nov 30, 2005
400
4
I am using XCode 2.2. I have a .dylib that corresponds to a library I have downloaded from the internet and built myself. I wish to be able to release my program without requiring users to download and build the library. I therefore wish to either embed the .dylib or statically link against it. How would I achieve this?
 

csubear

macrumors 6502a
Aug 22, 2003
613
0
Ah yes the joys of deployment.

What you want to do is have the dylib live in your bundle. Some people create a plug-in folder for it others just put it in your resouce directory. I'm lazy and just put it in the resource directory.

You also need to change the dylib's internal pathing. You can view this with the command otool -L yourlib.dylib at the terminal, and you can change the internal pathing with the command install_name_tool. It should be something like

install_name_tool -id @executable_path/../Resources/yourlib.dylib youlib.dylib


hope this helps.
 

Thomas Harte

macrumors 6502
Original poster
Nov 30, 2005
400
4
Okay, I have used install_name_tool in the way that you recommend and in XCode I have added a custom "Copy Files" build phase that copies the dylib to my Resources. Using otool on the binary in my application bundle reveals that it is now looking for @executable_path/<etc>, and checking my bundle reveals that my dylib does now turn up in the right place.

I therefore hope that I can just deploy the output of XCode without doing anything at the command line. I guess I'll find out!

EDIT: if anybody feels like testing, then I've uploaded to here (~ 956 kB). It "should" be compatible with 10.2 and above, but I've only tested on 10.4. It's an OS X port of a BBC Micro emulator by Tom Walker, with native menus and so on. It runs kind of slow because of some of the libraries it depends upon but anything 1 Ghz ish should run the emulator at full speed. The real question is: does it load up and run?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.