Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vtable for .. referenced from compile error xcode

Tags:

c++

xcode

iphone

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?

like image 745
Andres Avatar asked Sep 22 '09 05:09

Andres


People also ask

What is vtable C++?

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.

What is vtable and memory allocation in vtable?

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.

What is stored in vtable?

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.

What is use of vtable in in inheritance?

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.


1 Answers

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!

like image 165
Andres Avatar answered Oct 10 '22 13:10

Andres