Boost logo

Boost Users :

Subject: Re: [Boost-users] undefined reference to base_object
From: John C (johnc_at_[hidden])
Date: 2010-05-03 15:43:59


Well, I can say from extensive (and probably out of the ordinary) use of the
serialization library that it is NOT buggy, so hopefully anything I have
said did not imply it. In my opinion, templated code can be very complex and
compiler messages related to it can sometimes be extremely hard to decipher,
which is where I think most people run into issues.

If you are open to any suggestions on ways that I think might help other
users of the library, it doesn't look like the html here:

http://www.boost.org/doc/libs/1_42_0/libs/serialization/doc/index.html

has been updated in a while. For my case particularly, the portion in the
tutorial on serializing Derived Classes does not mention the use of the
BOOST_SERIALIZATION_BASE_OBJECT_NVP macro. I could see a first time user
trying the given code, running into issues, and then possibly deciding the
library is buggy since they couldn't figure out how to get it working. I
found the macro in someone else's post, which I then googled to figure out
what it was; then I found the boost/libs/serialization/test directory.
Everything in this directory I think can answer probably any question
someone might have about the serialization library usage, but they are most
likely going to look to the above link for help.

I also noticed that the release notes for boost 1.42.0 do not mention
updates for the serialization library - maybe I just missed them? I at first
didn't even bother looking at the latest release (and I don't think 1.41.0
mentioned anything either) until you said something...

Robert Ramey wrote:
>
> John C wrote:
>> Yeah, sorry, I suppose that sounds worse than what I intended. I
>> guess what I really mean is don't assume updates are backwards
>> compatible...
>
> Hmmm - they are meant to be. Sometimes an error is made but
> it's not THAT often. One thing that does occur is the following:
>
> a) things are going along just fine.
> b) A user posts a problem to the list. This turns out to be some
> some combination of DLLS, use of export, multiple instantications,
> virtual base classes, sharead pointer, collection serialization
> all nested with the user types.
> c) Something is wrong, but it's not easy to figure out.
> 1) Turns out to be a library bug. Does happen sorry. But the
> fix ends up breaking someone's usage. Hopefully, this just results
> in a compile time error which is easily fixed and we're done.
> 2) More often, it turns out to be an error on the part of the
> user about what the library can do or be expected to do. At
> this point I have two choices.
> i) resign my self to answering the same question forever.
> ii) ignore he user's problem, in which case he goes around
> reporting that "the serialization library is buggy" which of course
> annoys the hell out of me.
> iii) Enhance the code to trap the user error at compiler or
> maybe runtime. An explicit crash ASAP is better than a buried/hidden
> problem? Unfortunately, this will often trap errors in older code
> which are now report as new "bugs". What they really were were
> buried traps that no one has knowingly stepped in yet.
>
> This is not meant to be a rant. I'm just trying to make the
> library such that it's easy to use and hard to mis-use. I
> don't know how successful this effort has been, that is
> how many people have tried the library and found to
> frustrating to use, but there it is.
>
> Robert Ramey
>
>
>
>
>>
>>
>> Robert Ramey wrote:
>>>
>>> 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 mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>

-- 
View this message in context: http://old.nabble.com/undefined-reference-to-base_object-tp28417529p28439386.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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