Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
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?
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>
–
–
we'll start with the obvious bits: this suggests that the cpp is not linked in, or that the calls are referenced directly and not defined (you can define a pure virtual).
beyond that, there may be differences in build settings - generally, this is because of default symbol visibility (Xcode alias flags, and recommended settings):
GCC_INLINES_ARE_PRIVATE_EXTERN = NO
GCC_SYMBOLS_PRIVATE_EXTERN = NO
there are a few other build settings which could interfere -- idk how your projects are structured so... this list can become rather large.
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.