hi,
i am writing a simple c++ program to test the linking problem. i know that is it the beginner problem , but i really can't find the solution. i have written total 3 files - main.cpp, abc.cpp and abc.h.
abc.h:
class ABC
{
public:
void test(int i);
};
abc.cpp:
#include "abc.h"
#include <stdio.h>
#include <string.h>
void ABC::test(int i)
{
printf("testing success");
}
main.cpp:
#include <stdio.h>
#include <string>
#include "abc.h"
int main ()
{
ABC tabc;
tabc.test(3);
return 0;
}
I have tried the code in window VC6, there is no problem in exe. and running. But when i compile it under Linux with G++, the error occur in compiling to execute file.
the compilation statement:
g++ -o test.o -c main.cpp
g++ -o test test.o
error message is :
: undefined reference to `ABC::test(int)'
collect2: ld returned 1 exit status
i found that it may be the linking problem, but i can find the solution of that.
Thx for ur help!!
