Re: Interpreting "undefined symbols"
Re: Interpreting "undefined symbols"
- Subject: Re: Interpreting "undefined symbols"
- From: Greg Guerin <email@hidden>
- Date: Sun, 16 Dec 2007 11:46:16 -0700
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).
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.
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:
<http://lists.apple.com/archives/xcode-users/2007/Dec/msg00489.html>
or search the list archives for keywords: build transcript.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden