This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: undefined reference to `foo()'
- From: Gengis Kanhg Toledo "Ramírez" <gengiskanhg dot geo at yahoo dot com>
- To: gcc-help at gcc dot gnu dot org
- Cc: eljay at adobe dot com
- Date: Mon, 11 Dec 2006 13:55:43 -0800 (PST)
- Subject: 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