dynamic_cast failure while calling C++ API from Python
<p>I am attempting to call a C++ API from python. Following is the code in the pseudo form.</p>

<pre><code>class Engine { // Singleton Class which does a heavy duty work
public:
    static Engine* getEngine();
    bool init();
private:
    static Engine* m_instance;
    Engine();
};

// Following the code to wrap the call to engine to call from python
// Its only a simplified form

//engine_module.c
#include &lt;Engine.h&gt;
PyObject* initengine() {
    Engine* e = Engine::getInstance();
    e-&gt;init();
   // return the Py_BuildValue ...   
}

PyObject* initengine_module() {
//... init the module
}

// Python code
import engine_module
status = engine_module.init() 
</code></pre>

<p><strong>Problem:</strong>
The Engine class is in libengine.so and when it inits it fails because internally dynamic_cast fails. The Engine in turns loads other libraries using dlopen(). I searched the net to add RTDL_GLOBAL and -E option while linking but still its not resolved. Am I supposed to add the -E option while compiling the python itself? 
What could be the reason that Engine class works perfectly well when used in C++ code and does not work when used in python?</p>

<p><strong>Edit 1:</strong> 
To clarify on the question from Cat++: 
libengine.so has many other classes which internally in Engine::init() uses dynamic_cast&lt;>. The classes involved in dynamic_cast are not exposed to python at all. Only the Engine::init() is exposed.</p>

<p><strong>Edit 2:</strong>
The platform is Red Hat Linux and the compiler is Intel</p>
