[SDL] SDL under Mac OS X

Ryan C. Gordon icculus at clutteredmind.org
Sun Jan 16 11:21:41 PST 2005

> I want to build my game for OS X. SDL shouldn't be statically linked
> because my program isn't GPL. Should I use the "framework" or the
> UNIX-style shared lib system ?
> I'd like to be able to keep SDL in my game's directory, too.
> I googled and looked at the os x faq on libsdl.org but didn't find the
> answer.

Here's how I did it for ut2004 (which may not be the best way, but it 
was the cleanest in the long run, in my opinion):

Build SDL "the unix way"...unpack the source, and from a Terminal:

    cd /where/i/unpacked/SDL-1.2.8
    cd src

Let the thing compile for awhile. When it finishes, one of the last 
things in there should be the link command line...it starts something 
like this...

    gcc -dynamiclib  -o .libs/libSDL-  .libs/SDL.o

...and runs for 35 lines or so.

Cut and paste that command, making a small change:


      -install_name  /usr/local/lib/libSDL-1.2.0.dylib

  Change that to:

      -install_name @executable_path/libSDL-1.2.0.dylib

Take the library (.libs/libSDL-, on my system) and put it 
into your project. Link against that file. Now the program when run will 
look for "libSDL-1.2.0.dylib" in the same directory as the program.

This is a pain to set up, but is dead simple thereafter, in terms of 
packaging and distribution. Real Mac programmers are probably cringing 
right now and can offer a better solution, but this worked great for me.


More information about the SDL mailing list