Re: undefined reference to `foo()'

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

 



Thanks, it works.

The simple example was only a sample from the real
problem I have.
I have 10 .cc files and other amount of .h files, I
realize that order 
of files is important at the g   command. In my OOP
project I have some 
files as my own libraries used in several others
files, then it is not 
clear for me the order to be followed.

What is the order criteria?
Where can I get information about?

Thanks you very much.


John Love-Jensen escribió:
> Hi Ramirez,
> 
> Try this:
> 
> g   main.cc foo.cc -o prueba
> 
> HTH,
> --Eljay
> 
> 
> 

The problem:

$ 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();

$ 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


 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.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