Error with Release mode build: Zerolink?

Apprentice
Posts: 19
Joined: 2007.03
Post: #1
hey, I'm working in Xcode and I tried to do a release mode build of my game engine (which compiles just fine in debug mode) and it doesn't compile and gives the error:

/usr/bin/ld: warning multiple definitions of symbol _main

i've traced the problem to be Zerolink, turned off by default in release mode. The program compiles just fine with this turned on. Can someone tell me exactly what Zerolink is and why it might be causing this problem?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
Zerolink links the symbols at runtime as the program needs them rather than at compile time. It also won't let your programs be run anywhere but on your own computer. If you have multiple definitions of main, it could mean you accidentally defined main somewhere else and have forgotten about it, or it could also mean that you're including source files rather than just .h files. Or it could also mean that you have defined main in a .h file that's included into multiple files, or that your project somehow is set up to compile some files twice. (including the one with main in it) Without more information, it's impossible (for us, at least) to determine what possibility it is.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2007.03
Post: #3
ok so I got it to compile at least, but the duplication of main warning is because the standard SDL OpenGL template has 2 different main methods. I had just copied this verbatim and added my own code but since I changed the "main.c" file given in the template to a "main.cpp" file I have gotten these warnings. I'm a cocoa noob but I've poked around in the SDLmain.m file given with these templates and I can't figure out to get the warning to go away. I can't rename either of the main methods without it breaking.

Is there any way to fix this or will I just have to encapsulate my C++ code and change my main.cpp file to main.c?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
SDLMain.m contains it's own main function, which then in turn calls your own main function. However, in order to get it to work, you must include <SDL/SDL.h> (or at the very least SDLMain.h) in your main.cpp file, since it uses the pre-processor to re-name your main function to SDL_main, which is what's called from SDL's main function. So, in short, just add #include <SDL/SDL.h> to main.cpp.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  'Unidentified error' error in Xcode scgames 2 3,714 Jun 10, 2006 01:38 AM
Last Post: scgames
  XCode 2.1 and ZeroLink: unknown symbol NYGhost 1 3,506 Aug 24, 2005 09:10 AM
Last Post: NYGhost
  Debug build works on Panther, but not Release build... TomorrowPlusX 4 4,211 Jun 24, 2005 09:25 AM
Last Post: TomorrowPlusX