I’ve got a strange problem with SDL 1.2.8 on Mac
OS X 10.3.9. I wrote a little program that only
contains a main function that returns immediately.
As soon as I include SDL/SDL.h I cannot compile
the program anymore. The linker complains about
an undefined symbol _main. I use the following
command to compile my program:
gcc sdl.c -framework SDL -framework COCOA
Someone has already mentioned that you need to use the output of
’sdl-config --cflags --libs’ in your gcc command line, however since
you are using the framework version of SDL (which is the proper way
in OS X, in my humble opinion) you probably don’t have an sdl-config
script.
The easiest way to deal with this is to develop your project using
XCode. Once you install the SDL-devel package, you should have a
number of SDL project types to choose from when you create a new
project in XCode. It should set up all the compilation requirements
for you automatically.
If you really need to use the command line, however, you’ll need to
create your own ‘sdl-config’ script. I wrote a quick version for this
situation, which I keep in ~/bin. For ‘sdl-config --cflags’ it
outputs:
-F/Users/yourname/Library/Frameworks
-I/Users/yourname/Library/Frameworks/SDL.framework/Headers
-D_REENTRANT
For ‘sdl-config --libs’ it outputs:
/Users/yourname/bin/SDLMain.o -L/Users/yourname/Library/Frameworks
-framework Cocoa -framework SDL -lobjc
(Both of these outputs are only one line… and you should adjust them
according to where you installed the SDL framework.)
Finally, you’ll notice the SDLMain.o in the --libs output above. I
keep it pre-compiled for simplicity. You just need to grab SDLMain.m,
which is included in the developer stationary that comes with the
SDL-devel package. There are a few versions, use the one from the
"SDL Application" project stationary. Compile it with
gcc /path/to/sdl-config --cflags
-c SDLMain.m
to produce the .o file. Everything should work after that.__
Steve Saunders
Find local movie times and trailers on Yahoo! Movies.