I am trying to use the boost library to serialize on 64bit machine and de-serialize on 32bit machine. However, it seems it does not work. (I use 1.57.0).
If I run the following code
boost::asio::streambuf buf;
std::ostream os(&buf);
boost::archive::binary_oarchive oa(os);
printf("Buffer size %d\n",(int)buf.size());
The output of 32bit machine is 37 and the output of 64bit machine is 41.
Is there any other good serialize library I can Use? How about cereal?
It's great if the library can do compression as well (zlib/gzip etc.).
It does work. It just doesn't create compatible archives. If you want that you should look at the archive implementation that EOS made:
You can drop-in replace Boost's binary_[io]archive with it. No need to change anything else.
PS. Of course, spell out your types in an architecture-independent way too, of course. So uint32_t
, not ``size_t`