PDA

View Full Version : SDL game porting trouble: undefined symbols


destructive cactus
2005.07.25, 06:03 PM
I've been working on a mac port for the roguelike IVAN (http://ivan.sourceforge.net) for some time now. Here's the main error that is stopping me, all the way at the end during the linking process:


g++ -g -O2 -o ivan actset.o areaset.o charset.o charsset.o command.o coreset.o dataset.o dungeon.o game.o godset.o iconf.o id.o igraph.o itemset.o levelset.o main.o materset.o message.o object.o roomset.o script.o slotset.o trapset.o wmapset.o wskill.o ../..//FeLib/Source/libFeLib.a -L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL
ld: Undefined symbols:
_SDL_main


I was able to solve this in the previous builds by adding SDL.h and SDL_main.h to the file Main.cpp that called the main function. However, the previous builds weren't endian-agnostic so even after being built, the game couldn't get too far. The devs were kind enough to send me a new version for testing, however, even with my fix that worked last time, it doesn't seem to work. When googling for this error, I see a lot of other people with similar problems....has this ever been solved? If so, how?

Thanks!

OneSadCookie
2005.07.25, 06:27 PM
You meed to compile SDL_main.m too.

destructive cactus
2005.07.25, 07:12 PM
thanks for your reply.

does that mean I have to #include it like the other two?

OneSadCookie
2005.07.25, 09:33 PM
No, it's an additional source file. Compile it in a similar way to however you're already compiling the rest of the source files for the project.

destructive cactus
2005.07.28, 06:22 PM
When linking, -lSDLmain is present...that links to the compiled version of SDLmain.m, but there's still issues. From what I understand, I shouldn't also have to link to the source for that file, SDLmain.m...but I'd give it a shot if I knew how to include it in the build process...?

unknown
2005.07.28, 06:37 PM
gcc -g `sdl-config --libs` -lSDL_image -o GameName file1.o file2.o
works for me

destructive cactus
2005.07.28, 07:29 PM
Ah...I've found the issue. I had to pass this to the linker:

-lobjc

Compiled SDL uses objective C; I totally forgot! Thanks for all your help!