[Boost.Serialization] Derived class de-serialization problem due to MSVC linker

Hi,
I am trying to serialize a large set of objects in our library. I am
using the
Serialization library from version 1.33 with MSVC 2003. When I had all
serialization code in the header files of the classes, linking took too
much
time and memory. Therefore I am now using explicit template
instantiation
of the serialize function (see below) in conjunction with precompiled
headers
for the Boost.Serialization.
The problem is this: When I de-serialize a DerivedObject to a
BaseObject-pointer
(so that only the header of the BaseObject class is included) the linker
seems
to throw away the information from the explicit template instantiation
of the
DerivedObject in some cases. When I combine the explicit template
instantiation
and definition of serialize into one object for BaseObject and all
DerivedObject,
the linker keeps the registration information of the derived class
(because MSVC
uses object-level linking). Due to the coding standards in our
institution this
method was disapproved.
Is there a way to make the linker keep the registration information of
DerivedObject?
Best regards,
Markus Himmerich
.h-File:
----------------------------------------
namespace boost{
namespace serialization {
class access;
}
}
class BaseObject {
public:
...
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/);
}
.cpp-File:
----------------------------------
#include

[Boost.Serialization] Derived class de-serialization problem due to MSVC linkerThe problem is this: When I de-serialize a DerivedObject to a BaseObject-pointer (so that only the header of the BaseObject class is included) the linker seems to throw away the information from the explicit template instantiation of the DerivedObject in some cases. When I combine the explicit template instantiation and definition of serialize into one object for BaseObject and all DerivedObject, the linker keeps the registration information of the derived class (because MSVC uses object-level linking). Due to the coding standards in our institution this method was disapproved. Is there a way to make the linker keep the registration information of DerivedObject? *** Generally, the linker will discard any code not explicitly referred to. This is addressed by EXPORT which is non-standard and compiler dependent and "too clever". So it's not 100% relieable in all cases. My personal recomendation would be to create a small module which just refers to all your derived classes and link that in. But that would likely violate your organizations coding standards. I don't see a way to do this without changing you're organizations coding standards. Robert Ramey
participants (2)
-
Markus.Himmerich@oppenheim.de
-
Robert Ramey