Mircea Ispas
Mircea Ispas

Reputation: 20780

GCC linker error when building for iPhone

Undefined symbols:
"vtable for NameSpaceA::NameSpaceB::ClassA", referenced from:
__ZTVN4NameSpaceA17NameSpaceB15ClassAE$non_lazy_ptr in libSomeLib.a(SomeLib.bulk.o)
(maybe you meant: __ZTVN4NameSpaceA17NameSpaceB15ClassAE$non_lazy_ptr)

for some classes that are build in this lib. Same code compiles and links fine on Windows. Other classes from same lib are linked fine on Mac too. I don't have any build errors, only linker errors. Can you tell me some reasons for this kind of errors? I think that all virtual functions are implemented because it compiles and links fine on other platforms(not only Windows).

Upvotes: 2

Views: 171

Answers (1)

Mark B
Mark B

Reputation: 96233

In order for gcc to emit the vtables, each of your (polymorphic) classes needs to have at least one virtual, non-inline method. For example if your virtual destructor is inline currently, un-inline it and move it to the source file and that should fix it up.

Upvotes: 1

Related Questions