Compiling a SDL app under Mac OS X

I know it is a novice question. But here it goes:

I want to port a game a made for WIN32 to MacOS X. I’ve installed the
developer tools and the SDL, SDL_mixer and SDL_sound packages.
I’ve created a “new SDL application”. Added my source files and tried to
compile.

  • First of all: I copied the headers of OpenGL and SDL to the folders
    "GL" and “SDL” in mu sources folder (I don’t know if this is needed)
  • Then I managed to compile, but it says the following error: “Build
    failed (see build log for details)”, but where is the build log?
  • After that I tried to compile it using the “shell”, and I got the
    following error: “ld: multiple definitions of symbol _SDL_main”, in
    files “main_01.o” and “main_02.o”

Anyone can tell me what can it be? And another thing: have I to add the
"SDL_mixer" and “SDL_image” frameworks to my application? from the
"project -> “Add Frameworks…” option?

thanks

I know it is a novice question. But here it goes:

I want to port a game a made for WIN32 to MacOS X. I’ve installed the
developer tools and the SDL, SDL_mixer and SDL_sound packages.
I’ve created a “new SDL application”. Added my source files and tried
to
compile.

  • First of all: I copied the headers of OpenGL and SDL to the folders
    "GL" and “SDL” in mu sources folder (I don’t know if this is needed)

You don’t really have to do this. If SDL was installed correctly, the
new project should contain the search path you need. You can also use
#include “SDL_opengl.h” to access the headers (there is an FAQ on this).

  • Then I managed to compile, but it says the following error: “Build
    failed (see build log for details)”, but where is the build log?

The build log is in the lower half of the build pane (next to the find,
run, and debug panes). The build log probably says there are undefined
symbols. You’ll have to link to OpenGL (use the Add Frameworks menu for
this).

  • After that I tried to compile it using the “shell”, and I got the
    following error: “ld: multiple definitions of symbol _SDL_main”, in
    files “main_01.o” and “main_02.o”

Make sure the code you are compiling only contains one main() method
besides the one in SDLMain.m (use the find panel and search for
definitions of “main”). From your error it looks like you have
main_01.c and main_02.c included in the project which both have a
main() function in them.

Anyone can tell me what can it be? And another thing: have I to add the
"SDL_mixer" and “SDL_image” frameworks to my application? from the
"project -> “Add Frameworks…” option?

You could but that won’t quite work (you’ll still have to add the
header search path)

It would be best to do this for each (use command-option-e to open the
target settings pane):

  1. add ~/Library/Frameworks/<framework_name>.framework/Headers to the
    header search paths.
  2. add -framework <framework_name> to the OTHER_LDFLAGS build setting.
  3. make sure ~/Library/Frameworks is in the framework search paths

Note that <framework_name> should be “SDL_mixer” or "SDL_image"On Thursday, December 12, 2002, at 03:01 PM, sdl-request at libsdl.org wrote:

Beware that this will include glext.h. I had to add a hack to tell it
(as well as MingW) not to, since our project has its own. (mumble;
includes trying to be “helpful” …)On Sat, Dec 14, 2002 at 02:05:26PM -0500, Darrell Walisser wrote:

You don’t really have to do this. If SDL was installed correctly, the
new project should contain the search path you need. You can also use
#include “SDL_opengl.h” to access the headers (there is an FAQ on this).


Glenn Maynard

Heh, there’s already a define “NO_SDL_GLEXT” that you can turn on to
prevent SDL_opengl.h from including extensions.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Sat, Dec 14, 2002 at 02:05:26PM -0500, Darrell Walisser wrote:

You don’t really have to do this. If SDL was installed correctly, the
new project should contain the search path you need. You can also use
#include “SDL_opengl.h” to access the headers (there is an FAQ on this).

Beware that this will include glext.h. I had to add a hack to tell it
(as well as MingW) not to, since our project has its own. (mumble;
includes trying to be “helpful” …)

Oh, I thought I added that. (I’ve had to add quite a few things to SDL;
lost track.)

That means that I had to add that #define to my app in a couple places,
then. (Still an annoyance; not half as annoying as MingW’s gl.h system
header doing it, though.)On Sat, Dec 14, 2002 at 12:20:28PM -0800, Sam Lantinga wrote:

Heh, there’s already a define “NO_SDL_GLEXT” that you can turn on to
prevent SDL_opengl.h from including extensions.


Glenn Maynard

Thanks to all! My program is now compiled and working under OSX!!!