Boost logo

Boost Users :

From: Gavin Lambert (boost_at_[hidden])
Date: 2022-03-06 23:25:59


On 6/03/2022 00:21, Marc Viala wrote:
> On our platform (VS2019, Windows x64, Boost 1.77) an exception occurs
> during the serialization of an instance through its base pointer. This
> error is systematic and I was able to reproduce w/ a minimal use test
> (cf. enclosed archive). This use case includes a solution w/ a DLL
> project and EXE project. The EXE project is a simple unit-test. On my
> platform  when I execute the executable, I trigger an exception from
> Boost.Serialization ("unregistered void cast class cpe::derived_t<-class
> cpe::object_t"). I tried every recommandation that we can find on SO and
> Boost mailing lists without success. To be accurate, I prefer to mention
> that we are using Boost.Serialization Static Library flavor.

This last sentence is the cause of your problem.

If you wish to use static libraries, then you must use *only* static
libraries (or at least anything that is in a static library cannot
appear in your DLL ABI at all).

If you wish to use Boost.Serialization in your DLL ABI then you must use
the shared library variant only, such that both your EXE and DLL use a
common implementation. Otherwise they will each have independent copies
of the singletons.

If your DLL boundary exists only for unit testing, then switch your DLL
to a static library instead. If it exists for consuming by applications
other than just your unit test, then you have to ensure that Boost types
and concepts do not cross the DLL boundary if you want to use them as a
static library.


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