Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-05-06 00:25:01


I don't know whether your using 1.32 or CVS version. I also don't know the
larger context which would be helpful to explain the issue here.

First Problem
=========

The general idea is that one use

save(Archive & ar, const X & x, ...){
    ar << x.members ;
}

load(Archive & ar, X &x, ...){
    ar >> x.members;
}

OR

serialize(Archive & ar, X &x ){
    ar & x;
}

This permits const correctness in that Saving doesn't (and better not
because of tracking) change the state of x while Loading will in change it.

So
    a) if you're going to use the << operator make sure the operand is a
const reference
    b) if you're going to use the >> operator make sure the operand is NOT
a const reference
    c) if you're goingto use & it shouldn't be a const.
    d) If you can't easily do this, DONT make a copy use a cast instead. If
you make a copy it will break tracking of redundant saves.

Second Problem
===========
This pain it the neck is resolved with the next version (1.33) where the
serialization library implemetns auto_linking of the correct library for
platforms which support it>

For now you have to figure it out yourself.

> there are a lot of libraries

the ones called ..wserialization are for wide characters - exclude them for
now. That should leave only static and dynamic multi-thread versions.

> so I tried each one (library). Each produced
> different results with different linker errors ranging from multiply
> defined
> symbols to unresolved externals. One did compile, however:

I assume you meant one did LINK however - great.

> But the program crashes as soon as it is run with the error (an
> uncaught exception):

> I'm assuming this may be related to the fact that the 's' in
> libboost_serialization-vc71-s.lib means that the lib is compiled for
> single threads, and this is a multi threaded program. But of course,
> I'm probably wrong.

Hmm using the s.lib with a mulit-threaded CRT library would do it.
Try the folloing.

a) Try to build and execute the demo program.
b) Assuming your using the VC IDE. Look at the *.vcproj files that are
included with the package and compare them with your own.
c) once you've been able to get the demo to build in your environment, move
on to your own app.

Good luck.

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