I was getting the following error compiling an iPhone project:
"vtable for oned::MultiFormatUPCEANReader", referenced from:
__ZTVN4oned23MultiFormatUPCEANReaderE$non_lazy_ptr in MultiFormatUPCEANReader.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Anybody know how I may fix it?
V-tables (or virtual tables) are how most C++ implementations do polymorphism. For each concrete implementation of a class, there is a table of function pointers to all the virtual methods. A pointer to this table (called the virtual table) exists as a data member in all the objects.
Vtable is like an array of function pointer. Vtable and Vptr is creating at compile time which will get memory in run time and vtable entries are virtual function addresses . Every object of a class containing a virtual function will have an extra pointer which is pointing to Virtual Table is known as virtual pointer.
The vtable contains an entry for each virtual function accessible by the class and stores a pointer to its definition. Only the most specific function definition callable by the class is stored in the vtable.
You can imagine what happens when you perform inheritance and override some of the virtual functions. The compiler creates a new VTABLE for your new class, and it inserts your new function addresses using the base-class function addresses for any virtual functions you don't override.
The problem seemed to be that in the class MultiFormatUPCEANReader I had declared a constructor and destructor, but had not written a body for the destructor, this was causing this annoying problem. Hope this helps somebody solve their compile error. This is a terrible compiler error with little information!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With