Sérgio
Sérgio

Reputation: 303

Packing some macports libraries with executable file to create app bundle

I'm trying to create an application bundle for a game that uses some libraries I installed using macports. I would like to put the dependencies inside the bundle but am at loss on how to do that.

I've compiled the game and tried to use install_name_tool to change the path used so that the executable searches inside the bundle, I get no error but the path doesn't change. E.g.: install_name_tool -change libSDL-1.2.0.dylib @executable_path/../Frameworks/libSDL-1.2.0.dylib meandmyshadow

The executable was built using a CMake generated Makefile.

Would XCode be a better option? Is there anything I'm missing from the steps I'm taking?

Upvotes: 0

Views: 597

Answers (1)

ryandesign
ryandesign

Reputation: 1144

To answer your specific question about how to use install_name_tool: if you look at the library linkage of meandmyshadow using otool -L meandmyshadow it'll probably look something like this:

meandmyshadow:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
    /opt/local/lib/libSDL-1.2.0.dylib (compatibility version 12.0.0, current version 12.3.0)
    ...

When you use install_name_tool to change a reference in the program, you need to use the complete reference. You specified that you wanted to change the reference libSDL-1.2.0.dylib but you need to specify the absolute path, e.g. /opt/local/lib/libSDL-1.2.0.dylib:

install_name_tool -change /opt/local/lib/libSDL-1.2.0.dylib @executable_path/../Frameworks/libSDL-1.2.0.dylib meandmyshadow

As for the bigger question about how to include libraries into an application bundle, you can do it manually as you're doing above with install_name_tool, or consider trying dylibbundler which does it for you automatically. You can install it using MacPorts: sudo port install dylibbundler.

Upvotes: 1

Related Questions