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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux