This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Query:linking
- To: gcc at gcc dot gnu dot org
- Subject: Query:linking
- From: "Bipin T S" <bipin at lgsi dot co dot in>
- Date: Thu, 03 May 2001 15:51:04 +0530
I have just joined this list. I am facing some problems when i link .o
files created by gcc and g++ respectively.
In particular i had 3 files
1)Test.h
//Test.h
void print (int j) ;
2)Test.c
//Test.c
#include "Test.h"
void print(int j)
{
//print j...
}
3) Test1.cc
//Test1.cc
#include "Test.h"
int main()
{
print(2);
}
And i used gcc as follows
>gcc -c test.c //fine
>g++ -c test1.cc //fine
>g++ test.o test1.o //oops!!
i get the following error
test1.o : In function main()
test1.o (.text +0x6) :undefined reference to 'print(int)'
collect2: ld returned 1 exit status
I run RED Hat 6.2 gcc version egcs-2.9166
Can anyone tell me the reason for this behavior?
Thanks in advance!
Bipin