link error problem


 
Thread Tools Search this Thread
Operating Systems Linux link error problem
# 1  
Old 11-17-2004
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
# 2  
Old 11-17-2004
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
# 3  
Old 11-17-2004
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
# 4  
Old 11-18-2004
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 ...
# 5  
Old 11-18-2004
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
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Linux

Link command problem

Hello, I have one issue with linking folders. I have two domains (domain1 and domain2) on one server (centOS). In domain1, I have one folder containing many images which I want to share for domain2. So i have created link for image directory using below command. ln -s... (1 Reply)
Discussion started by: amitshah.in
1 Replies

2. Solaris

SUNW, hme0: Link Down - Cable problem

Ultra E150 Solaris 2.5.1 Oracle server. was working fine, then started losing network connection. I can see in messages file that it was complaining about another device using its ip address. Though not any longer, though I wonder if that was a red herring. My IT guys have now re-reserved its ip... (29 Replies)
Discussion started by: AlSmith1964
29 Replies

3. Shell Programming and Scripting

Soft link/file name problem

I want to find graphic files on an external disk then create soft links to those files in a folder on my machine. I have a problem with file names: if there are two graphic files in different directories but with the same file name, a link is created only for the first file i.e the 2nd file is... (4 Replies)
Discussion started by: stumpyuk
4 Replies

4. BSD

sym link problem

Hi, I am using Mac X 10.5. It's supporting BSD. I am getting strange problem. • Launch the terminal. • Create a directory. Use cd <directory> • Now create another directory test with command “mkdir test”. • Create a soft link with command “ln -s text.txt test” • Go to the test directory... (1 Reply)
Discussion started by: Saurabh78
1 Replies

5. OS X (Apple)

Sym Link problem

Hi, I am using Mac X 10.5. It's supporting BSD. I am getting strange problem. • Launch the terminal. • Create a directory. Use cd <directory> • Now create another directory test with command “mkdir test”. • Create a soft link with command “ln -s text.txt test” • Go to the test directory... (1 Reply)
Discussion started by: Saurabh78
1 Replies

6. Shell Programming and Scripting

problem with link creation!!!!

I have a home directory namely /pto/ppa/ridbmw/etl/ Now i have various directorys below the home directory. For eg from the home directory if i say cd /roddata it changes to that directory. I think its kind of link (I don't know if it's hard or soft). Now i need to create a new directory and... (4 Replies)
Discussion started by: dsravan
4 Replies

7. UNIX for Advanced & Expert Users

Ftp Link problem

I am using ftp services at my unix box and accessing it from windows. when i am giving the url in the browser, ftp://neeraj:neeraj@10.1.3.116/cat01/Ne.txt it is giving me ISA Server: extended error message : 200 Type set to I. 200 PORT command successful. 550 /cat01/Ne.txt: No such... (0 Replies)
Discussion started by: NeerajYadav
0 Replies

8. Programming

gcc Link problem

I have some crypting functions in object-file - for example,func.o Main file,from where crypting functions called, named as main.cpp . "gcc main.cpp -o main func.o" print "undefined reference to ... " But if I rename main.cpp to main.c and execute "gcc main.c -o main func.o" - ok. If anybody,... (3 Replies)
Discussion started by: Gigachel
3 Replies
Login or Register to Ask a Question