Boost logo

Boost :

Subject: Re: [boost] [serialization] Can one deserialize a derived classes viapointers to the base class using polymorphic archives in aDLL context?
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-02-13 12:07:58


Bogdan wrote:
>> As indicated in the boost documentation, the class serialization
>> will only have to be compiled once for all archive implementations
>> (present or
>> future). Therefore, the DLL should contain only the serialization
>> functions to the base polymorphic archives.
>>
>> While everything builds correctly, at run time I get a C++ exception
>> BEFORE main() in basic_serializer_map.cpp around the line 48:
>>
>>
>> // if this fails, it's because it's been instantiated
>> // in multiple modules - DLLS - a recipe for problems.
>> // So trap this here
>> if(!result.second){
>> boost::serialization::throw_exception(
>> archive_exception(
>> archive_exception::multiple_code_instantiation,
>> bs->get_debug_info()
>> )
>> );
>> }
>>
>> Please note BOOST_CLASS_EXPORT_IMPLEMENT is used only once per class
>> (inside polymorphic_derived2.cpp), yet the serializers are inserted
>> in the same map both from the Dll and from the executable.
>>
>> Am I doing something wrong? Has anyone been able to create a similar
>> working example? I really appreciate any feedback I could get.

It looks like polymorphic_derived2.cpp is being included in both the
mainline as well as the DLL.

It's not clear that polymorphic_base needs to be n the DLL and probably
shouldn't be.

Make sure that your header includes BOOST_CLASS_EXPORT_KEY and not
BOOST_CLASS_EXPORT.

finally, make sure that the test for this facility works.

Robert Ramey


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