Bogdan wrote:
3. serialization files in a separate dll. Both the main executable and my dll link with the dll version of the serialization library:
main.exe my_serialization.dll boost_serialization.dll
my_serialization.dll boost_serialization.dll
Builds OK but FAILS at runtime , at run time I get a C++ exception BEFORE main() in basic_serializer_map.cpp around the line 48:
'archive_exception::multiple_code_instantiation with the message "code instantiated in more than one module - polymorphic_base"'
This would indicate that the serialization for polymorphic_base is included in BOTH the mainline and the DLL. Check that the serialization function is NOT an inline definition. the polymorphic_base.cpp should only be needed when compiling the DLL.
option 1
include serialization definition for polymorphic_base in my_serialization.dll
option 2
include serialization definition for polymorphic_base in it's own dll.
4. serialization files in a separate dll. Both the main executable and my dll link with the static version of the serialization library:
main.exe my_serialization.dll boost_serialization.lib
my_serialization.dll boost_serialization.lib
Builds OK but FAILS at runtime while trying to serialize with the following exception thrown in oserializer.hpp(line 424):struct polymorphic::save():
'unregistered void cast class polymorphic_derived1<-polymorphic_base in function 'int __cdecl main(int,char *[])''
This is probably failing due to the compiler stripping out code not explicitly referred to. Since it's not referrred to, the linking doesn't include it from the library.
==================================================== Hello Robert, Thank you for your reply. The serialization functions are not inline: their bodies are defined inside the DLL. I did the following experiments: - I skipped manually the registration exception in the debugger and it turns out that all the serialized classes have their serializers registered twice. - if in the main function I do not call serialize/deserialize, the program runs ok; I agree with you, the program doesn't do anything but it proves that the registration is triggered by the actual usage of the serialization functionality and not by any eventual inline. I am under the impression I followed all the directions in the documentation and yet I keep hitting that glitch. Thank you, Bogdan PS. As for the case where boost serialization links as a static inside a user DLL, it fails, indeed, due to the compile stripping out code. Is there a workaround for this you would suggest?