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?

3 Answers3

2

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
  • 398,885
  • 90
  • 523
  • 479
  • 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? –  Aug 22 '10 at 07:05
  • 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 Aug 23 '10 at 15:23
  • 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? –  Sep 26 '10 at 05:03
  • You can use [install_name_tool](http://qin.laya.com/tech_coding_help/dylib_linking.html) to fix those paths. – mipadi Sep 27 '10 at 14:54
0

I had to just do this for jsoncpp. What I did was I went to linker settings under the project > Build Phases > Link Binary With Libraries then used the add other to go to my library's path and add the library from the folder which would be under opt/local/lib in the default setup for macport linker settings

getting the header files was a bit more complicated. In this case I had ended up going to usr/Include finding the file/folder with the headers, copying it into my project and in the cpp file I added the include line with quotation marks ("")

e.g., moved /usr/Include/json directory into the RestTemplate Project folder using copy. then added to main.cpp

#include "json/json.h"
ThinkBonobo
  • 15,487
  • 9
  • 65
  • 80
0

Try using py2app to create a stand-alone app.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151