Boost logo

Boost Users :

Subject: Re: [Boost-users] undefined reference to base_object
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-05-03 12:30:07


John C wrote:
> I think this was the main cause of my problem, and this alone might
> make it work in boost 1.40.0.
> Since the header file that uses this is in a shared object file that
> in some cases cannot have any boost dependencies, I had a forward
> declaration for base_object. I had to remove the forward declaration
> and #def in the inclusion of the boost export.hpp header for the
> BOOST_SERIALIZATION_BASE_OBJECT_NVP macro.

It's hard for me to guess what's going to happen if you start messing
with the header - especiallly if you only reveal this after the fact.

In order to limit dependencies, I would suggest a different technique.
Don't use inline definiition. Use the following in your class declaration:

template<class Archive>
void serialization(Archive & ar, const unsigned int version);

In a *.cpp file define the template and explicitly instantiate it
for the archive types that you use. This will permit you
to confine the inclusion of serialization library headers to
a smaller set of files.

When using serialization code (or any template code) with DLLS
this technique will also address another problem which is starting
to come up - Multiple (and potentially conflicting) template
instantiations. This could lead to hellish debug scenarios as well
as code bloat. In some cases the library can now detect this
problem, but I had to suppress the trap because it broke too
much user code. (That is, it detected too many problems in
user code.) When I have nothing else to do, I plan to revisit
this and provide a trap that the user will be able to explicitly
override. It might not help, but at least the user won't be able
to say he wasn't warned.

> The moral of the story:
> If you are upgrading boost versions, don't assume the serialization
> library hasn't changed drastically, especially if you are serializing
> polymorphic types and even if it works fine in Windows.
>

Well, the changes didn't seem drastic to me. I think that is an
overly harsh and missleading characterisation.

> Thanks for the help Robert....

Your welcome.

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