Please do not answer the question "how do I solve this error message?"
In the error message provided by gold:
/usr/bin/ld.gold: the vtable symbol may be undefined
because the class is missing its key function
What is a key function
? I find reference to it in the GCC manual page for Function Attributes under the section dllimport
. The relevant text reads:
On the SH Symbian OS target the dllimport attribute also has another affect (sic)—it can cause the vtable and run-time type information for a class to be exported. This happens when the class has a dllimport'ed constructor or a non-inline, non-pure virtual function and, for either of those two conditions, the class also has an inline constructor or destructor and has a key function that is defined in the current translation unit.
From this I take away that there is some function distinct from constructors or destructors, required under some conditions, when using the dllimport
attribute, on Symbian OS. Interesting, but I'm compiling for Linux on Linux, and grep -r dllimport
reveals nothing. So this paragraph does not apply.
(FWIW the problem derives (in this instance) from an undefined destructor but both the documentation and the output of the linker go to great pains to distinguish a "key function" from a destructor. For other kinds of missing symbols, the linker spells the name of the missing symbol.)
So, what is a key function
really?