Is it possible to use RTTI in a dynamic library ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The problem is under a Linux platform with gcc-3.2.2.
We've got an header containing the following (simplified):

class A
{
public:
   virtual bool fred1();
};

class B : public A
{
public:
   virtual bool fred2();
};

Included in a .so file (a dll in Windows terms)
and Included in an application

The .so file is loaded in a dynamic way: dlopen, dlsym, dlclose (LoadLibrary, GetProcAddress) and returns pointers to A objects.

What we want to do in the main application:

A *a = getFromSoFile(); // I'm sure this is a pointer to B in the real life
B *b = dynamic_cast<B *>(a);
--> The result is b == NULL;


Of course typeid(a) != typeid(B *)
but the strings returned by typeid(a).name() and typeid(B *).name() are equal.


Is there any way to make to make it work ? If we put everything directly in the program (no .SO file) it works as intended.


-- Loïc




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux