link error problem

Dear linuxers,

I'm a novice in C++ programming.
I wrote a ReadFile class in file ReadFile.cpp.
After that, I wrote a test.cpp, which contains a main function, to test whether my class work well.
I follow the following steps to compile the ReadFile.cpp file.
g++296 -c ReadFile.cpp -o ReadFile.o
g++296 ReadFile.o test.cpp -o test.o
I got two link error.
One mention that one of my funtions which called atoi contained in ReadFile.o was duplicated declared in file/tmp/xxxxxx.o(xxxxxx varies each time I link the program).
The other says one of the pointer in main function ReadFile *read_file_ = new ReadFile() was undefined reference to ReadFile's virtual table.

Would someone be kind enough to tell me how can I solve the problem?

Thanks in advance.

Sincerely,
Kun

g++296 -c ReadFile.cpp -o ReadFile.o
g++296 ReadFile.o test.cpp -o test.o

Where are u compiling test.cpp ???

i guess u need to compile test.cpp the way u are doing for ReadFile.cpp.

g++296 -c test.cpp -o test.o

create test.o

and try to create binary "test" by linking with test.o and ReadFile.o

Dear bhargav,

Thank you for your kind reply.
This is the way I did before.
It's true that I've made test.o and use ld to link both file.
But I failed again.
Tens of errors appeared.
It seems that they can't find the corresponding system library.
My system is RH AS3 Upate2.
Do you have any other suggestion?

Thank you any way.

Sincerely,
Kun

Can u show what are the errors u are getting ? I hope u are getting linking errors only.

Do u know what system libs u have to link ;

use -l to link those libs and use -L to give PATH of libs.

for ex .... if u want to link to liba.a which exists in /apps/c++/lib

g++296 test -o test.o ReadFile.o -la -L/apps/c++/lib ;

If u find it difficult ... find in google for some makefiles and use makefiles to build ...

Dear bhargav,

Thank you for your kindness.
It's true that I found the solution.
I declared a virtual destructor.
Unfortunately, I didn't implement it.
As a result, I got the error.

Thanks again for your help.

Sincerely,
Kun