Boost logo

Boost Users :

From: Sergey Skorniakov (s.skorniakov_at_[hidden])
Date: 2005-09-19 09:53:45


Had you defined BOOST_SERIALIZATION_DYN_LINK before including serialization
headers? 1.33 version implicitly links (via # pragma comment(lib, )) static
version of serialization library by default. Also, you can try to rename
static version of library to ensure that it is not used in linking. I'd got
similar strange errors before doing so.

"Topi Mäenpää" <topi.maenpaa_at_[hidden]> ???????/???????? ? ????????
?????????: news:432A942F.3030406_at_intopii.fi...
> Hi,
>
> How do I register classes that are defined in a dynamically loaded
> so/dll? Using BOOST_CLASS_EXPORT just causes "terminate called after
> throwing an instance of 'boost::archive::archive_exception'
> what(): unregistered void cast". My set-up is as follows:
>
> class A {
> public:
> A();
> virtual ~A() {}
> private:
> // polymorphic archive stuff here
> };
>
> class B : public A {}
>
> BOOST_CLASS_EXPORT(B);
>
>
> Serializing instances of B through a A* works fine if B is defined in
> the main executable. Now, I have tried the following (approximately):
>
> // An exported function that returns a void pointer
> typedef void* (*func)();
>
> int main()
> {
> // Load a dynamic library
> dll lib = load_dll("mylib.dll");
> // Get a pointer to the instance creator function
> func instance_creator = (func)lib.resolve("instance_creator");
> // An instance of B is created in the dll and returned as a void*.
> A* a = (A*)instance_creator();
>
> ...
>
> archive & a; //throws unregistered void cast
> }
>
> B is both defined and exported in mylib.dll.
>
> So, what is the deal? I don't understand the soul of BOOST_CLASS_EXPORT
> well enough to solve the problem myself. But since I'm using the dll
> version of the serialization library, I'd assume that the dynamically
> loaded dll (mylib.dll) and the main executable use the same address
> space for the archive classes. I would understand this if I encountered
> this problem with static linking because I'd need to inlude two copies
> of the serialization library...
>
> Any advice?
>
> Regards,
> Topi


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net