collect2 / ld giving strange errors with undefined virtual functions

Joe Buck jbuck@Synopsys.COM
Fri Mar 26 09:40:00 GMT 1999


> The feature I'm proposing is different: Whenever the linker ends up
> with an undefined symbol, it will print a message like
> 
> undefined reference to `A virtual table'
> There is no definition of `A::foo(int)'.

Here you'd have to let the linker know that it could expect to find
the definition of A's vtbl in the same file as the definition of
A::foo(int).  But you could get a better warning to the user with
less effort: all the linker needs to know is that a particular name
is that of a virtual table.

With Sun C++, you get the following message from the linker in cases like
this:

Undefined                       first referenced
 symbol                             in file
A::__vtbl                       fooo.o
[Hint: try checking whether the first non-inlined, non-pure virtual function of class A is defined]

(Both Sun C++ and g++ use the same heuristic to get one virtual function
table, so we could use the same warning in GNU ld or in collect).




More information about the Gcc mailing list