Re: Strange dynamic_cast problem
Re: Strange dynamic_cast problem
- Subject: Re: Strange dynamic_cast problem
- From: "Chris Suter" <email@hidden>
- Date: Tue, 4 Nov 2008 14:20:52 +1100
On Tue, Nov 4, 2008 at 9:09 AM, Eric Gorr <email@hidden> wrote:
> I have a strange problem with a dynamic_cast.
>
> I have put together a simple test project which can be found at:
>
> http://ericgorr.net/LibraryLoading.zip
>
> which demonstrates the problem.
I think you've hit a common problem with loading libraries at runtime
which is: by providing a definition of A and B's destructors in the
shared header, the compiler puts a copy of these, the virtual table
and the RTTI in each of the libraries so that when you load them,
there are two copies floating about and that confuses dynamic_cast.
One solution is to move the definitions into your main file and then
use the bundle_loader linker flag when linking your libraries. You'll
need restructure your project so that the main target is built before
the libraries and then you'll probably want a final target which
aggregates your main target with the libraries.
Another option that I think would work would be to create a third
library that contains the shared definitions and link your other
libraries against those.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden