LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-22-2005, 01:00 AM   #1
bianchi
Member
 
Registered: Nov 2005
Location: Italy
Posts: 36

Rep: Reputation: 15
Question undefined reference to ' vtable for CData'


buon giorno

I wrote 2 projects :
1. *.so file
2. *.exe file which uses the *.so file

I'm trying to build the exe file but I get some
linking errors of:
"undefined reference for 'vtable for CData'
.
.
.
."
many lines like this one for many classes.
I looked up on these classes and could not find
whats wrong.

anybody ??????????????



grazie infinite
 
Old 12-22-2005, 02:36 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Which libraries do you use?
 
Old 12-26-2005, 04:15 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Are you making an object file out of a template class that has virtual functions? Are you compiling a header file for a class with virtual functions instead of the source file?
ta0kira
 
Old 12-27-2005, 06:58 AM   #4
bianchi
Member
 
Registered: Nov 2005
Location: Italy
Posts: 36

Original Poster
Rep: Reputation: 15
Found !!!!
If you try to link to a library which has a class inside, and this class has
one or more virtual functions , but !!!! you dont have the implementation for the first ( and only for the first!!!!) virtual function you get the linking error of :'undefined reference to ' vtable for .....'
p.s. : if you have the implementation for the first one but , the second one does not have ,you will get the error : ''undefined reference to func-name'
 
Old 12-29-2005, 02:48 AM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I'm assuming the shared lib instantiates the class or uses member function pointers, otherwise it would not need to create a v-table; these are the situations where what you said is correct. If the shared lib doesn't need to instantiate a class that has virtual functions, it can still use the class without the function definitions. For example, if you had an abstract class, you could create objects of a class derived from the abstract class in main(), but also use them via pointers in a shared library by including the definition of the abstract class without including the definition of the derived class.
ta0kira
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined reference, why? george_mercury Programming 4 05-07-2009 12:15 AM
KDevelop: undefined reference bastl Programming 2 09-05-2005 09:52 AM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 03:01 AM
undefined reference mp4-10 Programming 3 01-25-2005 12:38 PM
undefined reference to machine_real_restart rickenbacherus Programming 0 06-07-2003 11:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration