Frequently Asked Questions: MacOS X


Table Of Contents


Q:What is supported?
A:SDL supports MacOS X 10.1 and newer, using either ProjectBuilder or the classic UNIX style build system.
Currently only ProjectBuilder can be used to build the SDL Framework. The UNIX build system creates a static version of the SDL library.

Q:What is SDLMain.m? Do I need it? Why is _main undefined?
A:Just like main() is the entry point for C programs (inc. C++, Objective-C, and Objective-C++), sdl_main() is the main entry point for SDL programs. However, you don't actually write an sdl_main() function. The header file "SDL_main.h" remaps your main() function to the sdl_main() function with a function macro. Your sdl_main() function is called after the code in SDLMain.m has performed the required "bootstrap" initializations to support the SDL runtime.

You *must* include SDLMain.m/.h in your application, because this is the code that defines SDL's entry point. If you fail to do this, it is likely that "_main undefined" will be thrown by the linker.

The second thing you *must* do is give your main() procedure the following prototype:

int main(int argc, char*argv[]);

Otherwise, the macro will not remap main() to sdl_main(), the bootstrap process will not run, and SDL will behave incorrectly or crash.

Q:I can't get OpenGL to work.
A:On Mac OS X, you access the OpenGL headers like so:

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>

The header file "SDL_opengl.h" accounts for the first two headers shown here on all supported SDL systems.

If you are are using Project Builder, add OpenGL.framework or GLUT.framework to your project. On the command line, add:

-framework OpenGL

to the GCC or LD arguments in your Makefile