views:

51

answers:

2

I'm trying to distribute my app's dependencies with the app.

I've got the macports packages librsvg, boost, and cairo installed 64-bit-only on my Snow Leopard system. When I create an .app bundle of my program, it does not work on machines without macports and the relevant libraries installed because they are not included with the app, which searches for the libraries in /opt.

I have tried the --static flag for static linking, but that caused libcrt0 errors.

What's the best method for linking MacPorts libraries and their dependencies to an OSX application suitable for lone distribution?

A: 

Try using py2app to create a stand-alone app.

Ned Deily
+1  A: 

You'll want to copy the libraries into your application bundle, using a Copy Files Build Phase. dylibs should be put in the Frameworks directory in the app bundle. You'll also have to add the libraries to your Xcode project.

mipadi
Should I rid myself of all of the macports header/library directories added into the header and library search paths?I'm guessing that in the Copy Files Build Phase under "Destination" I put 'Frameworks,' and the "Path" gets the path to the dylib in the macports folders?
Kyle Reynolds
In the Copy Build Files phase, you should set "Destination" to Frameworks, but leave "Path" empty -- just drag the libraries into the phase (you'll have to add them to your project first).
mipadi
I've added the .dylibs to the copy files phase, but after a build, otool still shows that the binary is depending on those .dylibs in /opt/local/lib. Is this normal?
Kyle Reynolds
You can use [install_name_tool](http://qin.laya.com/tech_coding_help/dylib_linking.html) to fix those paths.
mipadi