Re: [Boost-users] Boost Serialization & cross platform operability.

From: "John Spicer"
Date: Fri, 2 Jun 2006 16:52:25 -0400 Has anyone had any luck getting a serialized object (created using boost binary serialization) between two different platforms? I am currently using binary serialization on 32 bit & 64 bit machines without issue. However, passing the serialized objects between the two platform types fail. The serialized classes themselves support interoperability, and as such it appears that the serialization libraries themselves do not. I am assuming they are storing some type of meta data along with the payload?
Any thoughts on how to do this and keep with binary serialization?
-- John
Based on my own experience, boost binary archives are _not_ guaranteed to be portable between different hardware platforms. There are also some hints in the documentation, though I do not immediately recall where it is mentioned. (The problem is mostly due to endian mismatch and datatype size difference, if my memory is right.) What I did to counter this problem is to write a very simple subclass of binary archives and handle specifically the endian problem. The datatype size problem can be handled by serialization only types with specific size no matter on which platform, e.g. boost::int32_t, etc. Just 5 cents... Cheers, Freddie

Wu Yinghui, Freddie wrote:
From: "John Spicer"
Date: Fri, 2 Jun 2006 16:52:25 -0400 Has anyone had any luck getting a serialized object (created using boost binary serialization) between two different platforms? I am currently using binary serialization on 32 bit & 64 bit machines without issue. However, passing the serialized objects between the two platform types fail. The serialized classes themselves support interoperability, and as such it appears that the serialization libraries themselves do not. I am assuming they are storing some type of meta data along with the payload?
Any thoughts on how to do this and keep with binary serialization?
-- John
Based on my own experience, boost binary archives are _not_ guaranteed to be portable between different hardware platforms. There are also some hints in the documentation, though I do not immediately recall where it is mentioned. (The problem is mostly due to endian mismatch and datatype size difference, if my memory is right.)
The binary archive is not portable -- see: http://www.boost.org/libs/serialization/doc/special.html#portability for more. If you want portability between platforms the text or xml archives are your best bet. Jeff

Wu Yinghui, Freddie wrote:
Based on my own experience, boost binary archives are _not_ guaranteed to be portable between different hardware platforms.
well your experience agrees with the documentation. There are also
some hints in the documentation, though I do not immediately recall where it is mentioned. (The problem is mostly due to endian mismatch and datatype size difference, if my memory is right.)
What I did to counter this problem is to write a very simple subclass of binary archives and handle specifically the endian problem. The datatype size problem can be handled by serialization only types with specific size no matter on which platform, e.g. boost::int32_t, etc.
It sounds similar to the demo_portable_archive example included with B.S. Robert Ramey
participants (3)
-
Jeff Garland
-
Robert Ramey
-
Wu Yinghui, Freddie