Question

Is a boost binary archive "portable" from one Linux x86_64 machine to another Linux x86_64 machine?

The documentation suggests it is, by using the term native binary, however, I have not yet been able to do it. Is it "my fault", or is such a thing not possible?

I do know about portable binary archives, but I understand they are not tested well...

EDIT: In addition to SoapBox's answer, I figured out the boost library version needs to be the same on both machines

Was it helpful?

Solution

If both machines are The same version of 64-bit Linux on an x86-64 CPU, then you don't need any special "portability" code or options. The binary formats of these two machines are, by definition, identical. If one machine can load the archive then the other one also can.

This is not guaranteed but still usually true on different OSes as long as the underlying hardware is the same. (That is, 64-bit windows on x86-64 should be able to load an archive created on 64-bit Linux x86-64.)

If the processors are different, then you'll need to use a "portable" archive format. Boost.Serialization's text archives should be portable because the conversion to the non-portable binary representation is done from the text in the archive at load time.

OTHER TIPS

Late, but FWIW, there is a portable binary archive example in the boost serialization library. It's supposed to be faster than text archives, but I haven't personally run tests.

https://www.boost.org/doc/libs/1_70_0/libs/serialization/example/

The following files are pretty much copy & paste into your project:

portable_binary_archive.hpp

portable_binary_oarchive.cpp

portable_binary_oarchive.hpp

portable_binary_iarchive.cpp

portable_binary_iarchive.hpp

The portable_binary_oarchive and portable_binary_iarchive classes can be used as dropins in lieu of , for example, the text or non-portable binary archive classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top