As mentioned down on the link from @Jonas comment, the message "undefined reference to vtable" only happens if the first declared virtual method is not defined: https://stackoverflow.com/a/28458010/1274747
And as I tried just now, this is really the case: If the first declared overridden virtual method is not defined, I get the vtable error. If some other function down the line is not defined, I get undefined reference error of that particular method.
Example:
struct base
{
virtual ~base() {}
virtual int func1() = 0;
virtual int func2() = 0;
};
struct derived: base
{
virtual int func1();
virtual int func2();
};
// switch the comment to define one or the other
int derived::func1() // undefined reference to `derived::func2()'
// int derived::func2() // "undefined reference to `vtable for derived'"
{
return 5;
}
int main()
{
derived d;
return 0;
}
That means, check the first virtual function declared in the derived class (it might also be a virtual destructor).