On 19.10.2016 14:09, Jerry wrote:
> Hi,
>
> I'm stuck on a runtime error "undefined symbol: _ZTIN5eckit9ExceptionE" with a shared library libMagPlus.so. There was no error while building it, the error just was raised at runtime when Python module loading it.
>
> Symbol '_ZTIN5eckit9ExceptionE' was demangled into a readable symbol 'typeinfo for eckit::Exception'
>
> Checked with nm, the undefined symbol '_ZTIN5eckit9ExceptionE' is from a static library libOdb.a, which was static linked into libMagPlus.so, like this
Compiler-generated things like typeinfo and vtable are placed in some
certain translation unit by the compiler. I gather different compilers
can have different conventions, but one convention for vtable at least
is that it goes into the compilation unit which contains the definition
of the first non-inline virtual member function in the class. This
should probably be eckit::Exception::~Exception() in this case (it is
implicitly virtual because the base class destructor is virtual). I see
this symbol is undefined as well, so it looks like all this translation
unit is missing.
By default, when linking shared object (.so) files with g++, it does not
complain about missing symbols. This is a very nasty behavior IMO, but
fortunately this can be changed by adding
-Wl,-no-undefined
to the g++ linker line. If you do this, then you should start getting
errors already at link time of libMagPlus.so. If so, then you need to
figure out which library or compilation unit actually contains the
definition of eckit::Exception::~Exception() and other missing stuff,
and add this to the linker line.
Which compiler version are you using, BTW?
HTH
Paavo