[SDL] SDL under Mac OS X
bob at redivi.com
Sun Jan 16 18:52:00 PST 2005
On Jan 16, 2005, at 14:21, Ryan C. Gordon wrote:
>> 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
> 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-18.104.22.168.1.dylib .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-22.214.171.124.1.dylib, 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
> 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
That's close enough to the right solution. You should probably be
using a different path as per Apple's recommendation
(@executable_path/../Frameworks/libSDL-1.2.0.dylib), but there is
nothing technically wrong with yours. Additionally, rather than
cutting and pasting 35 lines of junk, you could use
install_name_tool(1) as a post-process on this dylib (works about 99.5%
of the time, in some edge cases install_name_tool will fail, but it
will tell you it failed), or edit the configure script and/or Makefile
to do this for you.
The Xcode project that SDL comes with will build a framework of this
style even easier. Basically, rip open the tarball, go to the
directory it creates, and type "xcodebuild". It should be
preconfigured to build a development-style framework. I'm not sure how
people think the library solution is easier (or why you feel the need
to build it yourself, unless you're patching it, but then you have LGPL
issues), but whatever floats your boat.
More information about the SDL