In your dll, are you explicitly instantiating template code for B? This
looks like the problem to me.
You'll have to use something like:
#include
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