LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   undefined reference to ' vtable for CData' (https://www.linuxquestions.org/questions/programming-9/undefined-reference-to-vtable-for-cdata-395531/)

bianchi 12-22-2005 01:00 AM

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

Mara 12-22-2005 02:36 PM

Which libraries do you use?

ta0kira 12-26-2005 04:15 PM

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

bianchi 12-27-2005 06:58 AM

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'

ta0kira 12-29-2005 02:48 AM

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


All times are GMT -5. The time now is 06:19 AM.