This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: undefined reference to `foo()'


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]