SDL game porting trouble: undefined symbols

destructive cactus
Unregistered
 
Post: #1
I've been working on a mac port for the roguelike IVAN for some time now. Here's the main error that is stopping me, all the way at the end during the linking process:

Code:
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!
Quote this message in a reply
Luminary
Posts: 5,125
Joined: 2002.04
Post: #2
You meed to compile SDL_main.m too.
Quote this message in a reply
destructive cactus
Unregistered
 
Post: #3
thanks for your reply.

does that mean I have to #include it like the other two?
Quote this message in a reply
Luminary
Posts: 5,125
Joined: 2002.04
Post: #4
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.
Quote this message in a reply
destructive cactus
Unregistered
 
Post: #5
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...?
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #6

gcc -g `sdl-config --libs` -lSDL_image -o GameName file1.o file2.o
works for me

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
destructive cactus
Unregistered
 
Post: #7
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!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Need help with undefined symbols error with Univeral app running under 10.3.9 dmdmdm 0 1,900 May 29, 2009 01:16 PM
Last Post: dmdmdm
  Error with Linking Symbols Oddity007 1 2,363 Feb 24, 2009 06:20 PM
Last Post: Oddity007
  Need help with undefined symbols error with Univeral app running under 10.3.9 Malarkey 1 2,820 Nov 12, 2006 12:23 PM
Last Post: OneSadCookie
  FlowerMan: PC-DirectX game for Macintosh - porting tools? MarekUhrin 13 6,291 Aug 9, 2006 11:21 AM
Last Post: MarekUhrin
  'Undefined Symbols' problem with Xcode 2.3. Any ideas, please!! scratt 6 5,318 Jun 11, 2006 10:19 AM
Last Post: scratt