Adam wrote:
....but this is what I've been working with forever! Really, these are the
same files that I've used since the last time I bugged you guys back in
September. And the weird thing is, I made a few simple modifications to the
code (and nothing to the main() function) and now it doesn't work. Was
there some sort of auto-update to Xcode that could be messing me up?
Because there's honestly no other way I can explain it.
Xcode doesn't auto-update, so that's not it.
I suggest backtracking the error from where it occurs: in the link step.
That means you need to look at all the symbols from the object-files being
linked, to find the definition of _main.
In your build folder, there's a ".build" sub-folder, and down in there a
couple levels should be any number of foo.o, bar.o, etc. for each foo.c,
bar.c source file. Use the 'nm' command on them to list the symbols. An
undefined or extern reference will be 'U', all defined symbols will have an
address and 'T' or 'D' (upper or lower case).
Is this the same for C++, because I did a search for it, and there was nothing...
If you don't find a definition for _main, then for some reason, the main()
in your source file isn't being compiled. My first guess on that would be
an unterminated or mis-terminated #if or #ifdef. That's a common cause for
huge tracts of missing code, in my experience. A second possible cause is
a #define macro expansion that somehow eliminates the code or its symbol.
A symbol can be "eliminated" as linkable (i.e. extern storage class) but
still exist if it has the 'static' keyword in front of it, so that's
another thing to look for.
I don't have any #ifs or #ifdefs or #defines in my code. I checked the number of brackets, and that checks out nicely. This is what my main() is:
int main(int argc, char *argv[])
{
initialize();
fileout << "Initialization complete." << endl << flush;
event_loop();
fileout << "Event loop finished." << endl << flush;
cout << endl << "Game over." << endl
<< "Your score is: " << score << endl
<< "Level " << level;
SDL_bool success;
success = SDL_RemoveTimer(timer);
SDL_Quit();
fileout << "Cleanup complete." << endl << flush;
return 0;
}
And I'm wondering if I need the int argc and char *argv[] things at the beginning- I had those when I was using GLUT, but now I'm using SDL, so does it appear that those parts are obsolete?
If you do find a definition for _main in one of your .o files, then you at
least know it's being compiled. See 'man nm' for what the symbol types
[TtDd] mean, because it might be the wrong type for some reason.
Knowing which .o file _main is in, you next need to look at the list of
files being linked, to make sure main's .o file is listed. Look at the
full link command in the detailed build transcript, find its -filelist arg,
then go look in the file-list file it refers to. That file contains text,
one pathname per line, for each file to be linked.
Here's a recent summary of instructions for how to view the build transcript:
or search the list archives for keywords: build transcript.
-- GG