Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] unregistered class exception during serialization from DLL
From: Robert Ramey (ramey_at_[hidden])
Date: 2013-07-14 12:27:54


Andreas Mainik wrote:
> Hello All,
>
> I have investigated the issue little bit more.
> I have observed the following:
>
> The code works properly after shifting of ~OrdBasis() definition into
> the source code.
> Hence, I suppose that compiler suite of MVSC 11.0 ignores in fact the
> results of A.CPP file.
> The result is obvious. Registration by
> BOOST_CLASS_EXPORT_IMPLEMENT(Ord<Options>) is not done.
>
> The same behavior was reproduced with MSVC 10.0 (Visual Studio 2010).
>
> Curiously, the situation depends on the code that is shifted to the
> source code file.
> The shifting of the Option class constructor in to the source code is
> not sufficient.
>
> Could anyone, please, check the behavior with other compilers.
>
> Is it a compiler suite (linker or compiler) bug? Or the problem with
> boost implementation?

The problem is that compilers attempt to eliminate code that doesn't
seem to be necessary. The inline version just get's elimnated and the
compiler/linker figures there's nothing left to do and won't even hook
the DLL. If you use the out of line code, it figures that you need to
include the DLL which in turn starts the whole chain of instantiation.
This is not some much a question of the serialization library as a
question about how to deal with generated code in a DLL. C++
currently has left undefined what should be done in cases like this.
The usage of DLLS trips a number of issues which are currently
undefined by the C++ standard - which barely touches on issues
of linking in any case.

Take a look at the examples in the package labeled "Polymorphic"
for some hints to get more predictable behavior in these cases.

Robert Ramey


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