Undefined symbol : typeinfo for eckit::Exception

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Undefined symbol : typeinfo for eckit::Exception


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"

                 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

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

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  \
... ...


But still got these undefined symbols

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

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


/// @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&);

    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)
        return s;


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

help-gplusplus mailing list
[hidden email]