Mac os x

I’m working on an SDL program that compiles and runs fine on Linux, but
I’d like it to run on OS X as well. Alas, I know practically nothing
about Carbon and Cocoa. I’m looking for pointers to some material that
would teach me at least how to create a simple menu, so that the app
would have at least the bear minimum, a menu with an About and Quit and
maybe a few other features (e.g. fullscreen/windowed mode).
Furthermore, I want to build a statically linked universal binary that
can be bundled so that installation is easy (it’s going to be open
source so statical linking is OK, but less tech savy Mac users do not
like to download and install libraries before installing programs).

Any pointers to docs available over the Net would be much appreciated.

By the way, sdl-config --static-libs does not really return the static
library, it returns exactly the same as --libs. Is it deliberate or
just a bug? It would be nice if it actually returned the full pathname
to the static library.

Thanks,

Zoltan

It’s not that hard.

But you should work on MacOSX with Xcode, I have no idea if there is
any way to compile it otherwise.

Then, in Xcode:

If you use the sample SDLMain.m provided by SDL (it’s a small ObjC
wrapper which calls your main() function) and link to the
SDL.framework (and other frameworks you need for your project), it
should work already so far. For most SDL subprojects (like SDL_image,
SDL_mixer and so on) there are also MacOSX frameworks (a MacOSX
framework is a set of all the headers, the library and other related
stuff). MacOSX itself has also already a huge set of standard
libraries (like libxml2 and others) and you can link to them as under
Linux. For other libraries, try to find also a MacOSX framework. You
can include later these frameworks in the application bundle. And I
would link the rest statically in.

  • Albert

(If you want to see a non-trivial example, you can check out the SVN
of our OpenLieroX project and then read the doc/Development for
further instructions. There is also a Xcode project file in the SVN.)Am 05.12.2008 um 22:45 schrieb Zolt?n K?csi:

I’m working on an SDL program that compiles and runs fine on Linux,
but
I’d like it to run on OS X as well. Alas, I know practically nothing
about Carbon and Cocoa. I’m looking for pointers to some material that
would teach me at least how to create a simple menu, so that the app
would have at least the bear minimum, a menu with an About and Quit
and
maybe a few other features (e.g. fullscreen/windowed mode).
Furthermore, I want to build a statically linked universal binary that
can be bundled so that installation is easy (it’s going to be open
source so statical linking is OK, but less tech savy Mac users do not
like to download and install libraries before installing programs).

Any pointers to docs available over the Net would be much appreciated.

By the way, sdl-config --static-libs does not really return the static
library, it returns exactly the same as --libs. Is it deliberate or
just a bug? It would be nice if it actually returned the full pathname
to the static library.

Thanks,

Zoltan


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Personnally, I use the “fink” package system.
The main advantage is that I can compile my source code on Linux and Mac OS X with minor changes.
Also, I strongly advise you to use “sdl-config” and never include SDL with the “SDL” prefix, or your code will mess (and so on for SDL derived libraries like SDL_image).

A typical compilation line is:

gcc progsdl.c -o progsdl $(sdl-config --cflags --libs)

On Mac OS X, with fink, it will be perfectly OK.
Note that you can replace the $(some stuff) notation by some stuff

The drawback of this method is that it builds “console” applications, so you need to make your own Mac OS X package if you want your binary beeing embedded in a Mac OS X Application tree. Using XCode and the SDL Mac OS X packages avoid this trouble.

Hope this can help

Cheers
Julien