Boost logo

Boost :

From: Stephan Diederich (stephan.diederich_at_[hidden])
Date: 2007-07-11 15:52:32


On 7/2/07, Stephan Diederich <stephan.diederich_at_[hidden]> wrote:
>
> On 6/29/07, Jeremy Pack <rostovpack_at_[hidden]> wrote:
> > On 6/29/07, Stephan Diederich <stephan.diederich_at_[hidden]> wrote:
> > > On 5/29/07, Jeremy Pack <rostovpack_at_[hidden]> wrote:

[snip]

> > For part 2, this can actually be done using RTTI - just dynamic_cast it.
> > >
> > > Works, thanks! I thought it wouldn't be possible to dynamic_cast a
> > > type from another library, but it seems to work... Any ideas if this
> > > can cause problems?
> >
> > If I recall correctly, there is the possibility of problems using an
> older
> > (much older) version of Borland C++. I read about it on some Borland
> help
> > site once while designing the library. I think I've written it in a way
> that
> > will overcome even those problems - but we won't find out until we've
> run
> > the unit tests on more machines. Thus far, we've found no issues on any
> > compiler.
> That sounds comfortable. I read about problems with any_cast where
> typeid is used to compare the type in any and the type to cast to
> (http://tinyurl.com/38ztc4), but actually I couldn't reproduce them
> with VC8, darwin and gcc.

Hi Jeremy,
today I was able to reproduce them. I had to switch from cmake to qmake (on
linux, gcc-4.1), and with that my compiler options switched, too.
I think I figured out two things, to make the above work.
First, the executable needs to be linked with "-rdynamic". With that flag
enabled, dlopen merges the weak symbols from the loaded library with the
ones from the executable. (including rtti-information).
Second, the call to dlopen a library should be passed RTLD_GLOBAL. With that
flag enabled, symbols from this library are candidates for merging (which
again seems to remove doubled rtti symbols).
Only with that set I was able to dynamic_cast "between" shared libraries.
Maybe its worth mentioning that in the docs of boost::extension.

Do you have an idea how this is done on windows?

Cheers,
Stephan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk