boost::archive::binary_(i/o)存档可移植性

发布于 2024-12-16 13:52:19 字数 220 浏览 3 评论 0原文

boost 二进制存档是否可以从一台 Linux x86_64 机器“移植”到另一台 Linux x86_64 机器?

文档表明,通过使用术语“本机二进制文件”,但是我还无法做到这一点。这是“我的错”,还是这样的事情不可能?

我确实了解便携式二进制档案,但我知道它们没有经过很好的测试...

编辑:除了 SoapBox 的答案之外,我发现两台机器上的 boost 库版本需要相同

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瀟灑尐姊 2024-12-23 13:52:19

如果两台机器都是 x86-64 CPU 上相同版本的 64 位 Linux,那么您不需要任何特殊的“可移植性”代码或选项。根据定义,这两台机器的二进制格式是相同的。如果一台机器可以加载存档,那么另一台机器也可以。

虽然不能保证这一点,但只要底层硬件相同,在不同的操作系统上通常仍然如此。 (也就是说,x86-64 上的 64 位 Windows 应该能够加载在 64 位 Linux x86-64 上创建的存档。)

如果处理器不同,则需要使用“可移植”存档格式。 Boost.Serialization 的文本档案应该是可移植的,因为到不可移植的二进制表示的转换是在加载时从档案中的文本完成的。

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.

眼前雾蒙蒙 2024-12-23 13:52:19

晚了,但是FWIW,boost序列化库中有一个可移植的二进制存档示例。它应该比文本档案更快,但我还没有亲自进行测试。

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

以下文件几乎都是复制和复制的。粘贴到您的项目中:

portable_binary_archive.hpp

portable_binary_oarchive.cpp

portable_binary_oarchive.hpp

portable_binary_iarchive.cpp

portable_binary_iarchive.hpp

portable_binary_oarchiveportable_binary_iarchive 类可以用作 dropin 来代替,例如,文本或非- 可移植的二进制归档类。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文