When compiling in debug mode my xcode compilation has these linking errors:
"<method name>", referenced from:
Vtable for <classname>in <objectfile.o>
"non-virtual thunk to <method name>", referenced from:
Vtable for <classname>in <objectfile.o>
the strange thing is: It only occurs in one of my build targets (both targets are pretty much the same for that code), plus if these methods are defined in the header file instead of the .cpp it works fine for both targets.
All of those methods are pure virtual. The class where these errors occur inherits from multiple classes but only one of those causes these errors.
Anyone has any idea of what is causing this error?
Show activity on this post. vtable and typeinfo are internal structures generated by the C++ compiler. vtable is used for calling virtuable functions and typeinfo is used for RTTI. Different compilers have different strategies for when they generate these structures.
If Obstacle is an abstract base class, then make sure you declare all its virtual methods "pure virtual": The = 0 tells the compiler that this method must be overridden by a derived class, and might not have its own implementation.
The = 0 tells the compiler that this method must be overridden by a derived class, and might not have its own implementation.
Got hit by the same issue. It simply happened when we defined a virtual member function (in the .h header file) but not implemented it (in the .cpp file).
In my case, the implementation was inside a #define that prevented to be actually compiled. GCC should have more explicit message for that kind of common mistake such as
virtual function <function> defined but not implemented in class <class>
Encountered this issue when developing with C++/QtCreator, it was caused by including the same file multiple times in the .pro file. Make sure to check each necessary header/source file is only listed under HEADERS += \
and SOURCES += \
once!
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