Mac OSX compilation woes

I am trying to build a nehe opengl/sdl sample on Mac OSX. I have the SDL
framework installed.

g++ lesson05.c -o lesson05 -framework SDL -framework OpenGL -framework Cocoa

yields:

/usr/bin/ld: Undefined symbols:
_main

The SDL macosx faq states:
You must include either SDLMain.m/.h or libSDLmain 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.

I have no libSDLmain.

I do not understand how to include SDLMain.m (I don’t know Cocoa or Objective-C).

What should I do?

Thanks for any help

g++ lesson05.c -o lesson05 -framework SDL -framework OpenGL -framework Cocoa
yields:
/usr/bin/ld: Undefined symbols:
_main

I do not understand how to include SDLMain.m (I don’t know Cocoa or Objective-C)
What should I do?

Please read the documentation inside the SDL-1.2.9.dmg. It covers this
topic in detail.

-Eric

AzCoder wrote:

g++ lesson05.c -o lesson05 -framework SDL -framework OpenGL -framework Cocoa

yields:

/usr/bin/ld: Undefined symbols:
_main

I do not understand how to include SDLMain.m (I don’t know Cocoa or Objective-C).

g++ lesson05.c …/wherever/SDLMain.m -o lesson05 -framework SDL
-framework OpenGL -framework Cocoa

(How are you including SDL.h? If you are doing ‘#include “SDL.h”’, as
recommended for portability, I think there should be an additional
’-I/Library/Frameworks/SDL.framework/Headers’. But as it seems to work
for you without that, I left it away.)

SDLMain.m is in /Library/Application Support/Apple/Developer
Tools/Project Templates/Application/SDL Application/ on my system, but
I’m not sure if that’s where the latest installer installs it. Search
for it.

Hope that helps

-Christian

(By the way: I just saw that the current SDLMain.m uses methods only
present on 10.4, which presumably means it won’t work correctly on 10.3
and 10.2. I’ll look into fixing that.)