XCode link error SDL_main (SDL 1.3)

I know this is supposed to be in the faq, but I can’t get it to work
at all… even the samples in /SDL-1.3/XCode/TemplatesForXcode/ don’t
work :frowning:

i keep getting the duplicate symbol error :

duplicate symbol _main in /Users/jeroen/SDL-1.3/Xcode/
TemplatesForXcode/SDL Cocoa Application/build/SDLCocoaApp.build/
Debug/?PROJECTNAME?.build/Objects-normal/i386/main.o and /Users/jeroen/
SDL-1.3/Xcode/TemplatesForXcode/SDL Cocoa Application/build/
SDLCocoaApp.build/Debug/?PROJECTNAME?.build/Objects-normal/i386/
SDLMain.o

can anyone give me a hint on this ? I noticed that both SDLmain.m and
main.c have a main routine, so I tried commenting out one of them, but
in both cases that results in a link error with _SDL_main not found…

i’m totally stuck here :frowning:

2008/9/9 Jeroen Clarysse <jeroen.clarysse at telenet.be>

I know this is supposed to be in the faq, but I can’t get it to work at
all… even the samples in /SDL-1.3/XCode/TemplatesForXcode/ don’t work :frowning:

i keep getting the duplicate symbol error :

duplicate symbol _main in /Users/jeroen/SDL-1.3/Xcode/TemplatesForXcode/SDL
Cocoa
Application/build/SDLCocoaApp.build/Debug/?PROJECTNAME?.build/Objects-normal/i386/main.o
and /Users/jeroen/SDL-1.3/Xcode/TemplatesForXcode/SDL Cocoa
Application/build/SDLCocoaApp.build/Debug/?PROJECTNAME?.build/Objects-normal/i386/SDLMain.o

can anyone give me a hint on this ? I noticed that both SDLmain.m and
main.c have a main routine, so I tried commenting out one of them, but in
both cases that results in a link error with _SDL_main not found…

i’m totally stuck here :frowning:


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

Hi,
Well actually I’m afraid that the XCode projects haven’t been updated after
the GSoC merge(or maybe something missed me out;)), so it’s a case, where
you have to hit on Sam.

Best wishes–
“For those about to code”
–Szymon “Wilku” Wilczek

when comparing SDL_main.h between sdl 1.3 and sdl 1.2.13, there is a
difference in the preprocessor where main is redefined :

SDL 1.2.13 defines :

#if defined(WIN32) ||
(defined(MWERKS) && !defined(BEOS)) ||
defined(MACOS) || defined(MACOSX) ||
defined(SYMBIAN32) || defined(QWS)

while SDL 1.3 defines

#if defined(WIN32) ||
(defined(MWERKS) && !defined(BEOS)) ||
defined(SYMBIAN32) || defined(QWS)

so the mac isn’t there anymore… is that intentional ???

Well actually I’m afraid that the XCode projects haven’t been
updated after the GSoC merge(or maybe something missed me out;)), so
it’s a case, where you have to hit on Sam.

yea… i was wondering a bit about that… now Sam did an upload from
CVS to the downloadable zip a while a go for me, and I got the SDL
compiled properly after that. So my guess was that the mac is
compatible with SDL 1.3 already

seemingly the templates are not. I can only hope that someone with
more XCode experience has thrown himself on it with some results

fingers crossed.

(i could of course start with the windows version, and work towards
mac later, but I don’t like the windows compiler :slight_smile:

YAY ! solved it !!!

i think that, changing the #define and recompiling the framework fixes
it !!!

lets hope I did not break anthing else in the process :-)>

when comparing SDL_main.h between sdl 1.3 and sdl 1.2.13, there is a
difference in the preprocessor where main is redefined :

SDL 1.2.13 defines :

#if defined(WIN32) ||
(defined(MWERKS) && !defined(BEOS)) ||
defined(MACOS) || defined(MACOSX) ||
defined(SYMBIAN32) || defined(QWS)

while SDL 1.3 defines

#if defined(WIN32) ||
(defined(MWERKS) && !defined(BEOS)) ||
defined(SYMBIAN32) || defined(QWS)

so the mac isn’t there anymore… is that intentional ???


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

I’m a bit puzzled : i understand the need for “patching” main() on
some platforms, but on mac, it gets really weird…

the templates have TWO mains : one in “main.c”, and one in
"SDLmain.m" (not to be confused with SDL_main in the framework… IMHO
it is rather funky to name them so similar)

the main in main.c is clearly a true mainloop routine since it
initializes everything, polls the keyboard, and then cleans up

the one in main.h is a pre-initializer, since it parses argc and argv,
and then dispatches to either NSApplicationMain or
CustomApplicationMain. I’m not experienced with objC, so i have no
clue how these handle the passthrough, but what leaves me wonrdering
is :

both these files include SDLmain.h, and thus both of these could run
the preprocessor directive that replaces main() with SDL_main()…

how does XCode know which one to do first ? There is an #ifdef
_SDL_main_h directive, so the replacement only happens ONCE…

heavy stuff :slight_smile:

yea… i was wondering a bit about that… now Sam did an upload from
CVS to the downloadable zip a while a go for me, and I got the SDL
compiled properly after that. So my guess was that the mac is
compatible with SDL 1.3 already

seemingly the templates are not. I can only hope that someone with
more XCode experience has thrown himself on it with some results

Yes, the SDL library itself has been updated so main() doesn’t need to
be overridden anymore, but the templates haven’t been updated yet. I’ll
see if I can get Eric to update them. :slight_smile:

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment