How to use "nm" for "undefined reference" problem catch.

Gengis Kanhg Toledo Ramírez gengiskanhg.geo@yahoo.com
Thu Dec 14 23:39:00 GMT 2006


The problem:

$ g   ./main.cc -o prueba
/home/<myname>/tmp/ccEOfejM.o(.text 0x11): In function
`main':
: undefined reference to `foo()'
collect2: ld returned 1 exit status

$ nm *.o
 
         foo.o:
00000000 T _Z3foov

main.o:
          U __gxx_personality_v0
00000000 T main
          U _Z3foov


***U = undefined, but foo() is defined by #include
"foo.h" in main.cc


$ more *.cc *.h
::::::::::::::
foo.cc
::::::::::::::
#include "foo.h"

int foo()
{
     return 42;
}
::::::::::::::
main.cc
::::::::::::::
#include "foo.h"

int main()
{
     return foo();
}
::::::::::::::
foo.h
::::::::::::::
int foo();




I realize that compiling and linking this simple
example I going to 
solve my real problem from my larger project.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Gcc-help mailing list