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 |
Which libraries do you use?
|
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 |
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' |
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. |