ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.