Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Undefined symbol : typeinfo for eckit::Exception

35 views
Skip to first unread message

Jerry

unread,
Oct 19, 2016, 7:10:54 AM10/19/16
to
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


nm -Cl libOdb.a | grep -i "eckit::Exception"

<code>
U eckit::Exception::Exception(std::string const&, eckit::CodeLocation const&) /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:84
U eckit::Exception::~Exception() /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:108
0000000000000000 W eckit::Exception::retryOnClient() const /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:48
0000000000000000 W eckit::Exception::retryOnServer() const /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:47
0000000000000000 W eckit::Exception::terminateApplication() const /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:49
0000000000000000 W eckit::Exception::what() const /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:46
U eckit::Exception::print(std::ostream&) const
U typeinfo for eckit::Exception
</code>

I also tried to unpack all object files from libOdb.a and relink libMagPlus.so with all of them with option '-fvisibility=default -rdynamic', like this

<code>
ar x libOdb.a ( ./Odb )

/usr/bin/g++ -fvisibility=default -rdynamic -fPIC -pipe -O2 -g \
-Wl,--disable-new-dtags -shared \
-Wl,-soname,libMagPlus.so -o ../lib/libMagPlus.so \
... ... \
./Odb/*.o \
... ...

</code>

But still got these undefined symbols

<code>
U eckit::Exception::~Exception() /opt/src/OdbAPI-0.10.2-Source/eckit/src/eckit/exception/Exceptions.h:108
U eckit::Exception::print(std::ostream&) const
U typeinfo for eckit::Exception
<code>

Here are the the header that defines eckit::Exception class.

<code>
Exceptions.h

/// @brief General purpose exception
/// Derive other exceptions from this class and implement then in the class that throws them.
class Exception : public std::exception {

public: // methods

/// Constructor with message
Exception(const std::string& what, const CodeLocation& location = CodeLocation() );

/// Destructor
/// @throws nothing
~Exception() throw();

virtual const char *what() const throw() { return what_.c_str(); }
virtual bool retryOnServer() const { return false; }
virtual bool retryOnClient() const { return false; }
virtual bool terminateApplication() const { return false; }

static bool throwing();
static void exceptionStack(std::ostream&,bool callStack = false);

const std::string& callStack() const { return callStack_; }

protected: // methods

void reason(const std::string&);
Exception();

virtual void print(std::ostream&) const;

private: // members

std::string what_; ///< description
std::string callStack_; ///< call stack
SavedStatus save_; ///< saved monitor status to recover after destruction
Exception* next_;
CodeLocation location_; ///< where exception was first thrown

friend std::ostream& operator<<(std::ostream& s,const Exception& p)
{
p.print(s);
return s;
}
};

</code>


I knew little about C++, and have no idea how to get this fixed. Wondering if needs to touch Exceptions.h and how to touch it ?

Anybody can help ?

Appreciating your time

Regards

Juha Nieminen

unread,
Oct 19, 2016, 8:18:59 AM10/19/16
to
Jerry <jerr...@gmail.com> wrote:
> 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.

It sounds like a dynamic library requiring that symbol from another dynamic library,
the latter of which is not being properly loaded.

Without knowing the exact system you are using (especially since I have no idea how
C++ libraries are used in Python), I can't be of any more help than that.

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Paavo Helde

unread,
Oct 19, 2016, 9:27:51 AM10/19/16
to
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

Jerry

unread,
Nov 4, 2016, 5:11:34 AM11/4/16
to
Paavo,

Thanks for your kindly inputs.

'-Wl,-no-undefined' did give a lot help to find all missing stuff, and help to fix the issue.

Appreciating your time

Regards

Jerry
0 new messages