便携式存档不在GCC下编译

时间:2011-04-21 13:55:18

标签: c++ boost boost-serialization

我需要(在)Windows和Linux上(de)序列化数据(并在其间传输文件)。我想使用Boost序列化库的可移植二进制存档,可以在示例中找到,参见例如在http://boost-doc-zh.googlecode.com/svn-history/r380/trunk/libs/serialization/example/

这适用于Windows(VS 2008),但无法在GCC 4.3.2下编译,但有以下错误。

有人可以提出解决方案吗?

非常感谢!

/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp: In member function 'void portable_binary_iarchive::init(unsigned int)':
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp:78: error: 'uint_least32_t boost::archive::version_type::t' is private
/home/myfolder/src/portable_binary_iarchive.cpp:92: error: within this context
/home/myfolder/src/portable_binary_iarchive.hpp: In member function 'void portable_binary_iarchive::load(T&) [with T = boost::archive::class_id_type]':
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:107:   instantiated from 'static void boost::archive::load_access::load_primitive(Archive&, T&) [with Archive = portable_binary_iarchive, T = boost::archive::class_id_type]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:356:   instantiated from 'static void boost::archive::detail::load_non_pointer_type<Archive>::load_primitive::invoke(Archive&, T&) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:433:   instantiated from 'static void boost::archive::detail::load_non_pointer_type<Archive>::invoke(Archive&, T&) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:586:   instantiated from 'void boost::archive::load(Archive&, T&) [with Archive = portable_binary_iarchive, T = boost::archive::class_id_type]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/common_iarchive.hpp:66:   instantiated from 'void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/home/myfolder/src/portable_binary_iarchive.hpp:140:   instantiated from 'void portable_binary_iarchive::load_override(T&, int) [with T = boost::archive::class_id_type]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/interface_iarchive.hpp:60:   instantiated from 'Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/common_iarchive.hpp:51:   instantiated from 'void boost::archive::detail::common_iarchive<Archive>::vload(boost::archive::class_id_type&) [with Archive = portable_binary_iarchive]'
/home/myfolder/src/portable_binary_iarchive.cpp:128:   instantiated from here
/home/myfolder/src/portable_binary_iarchive.hpp:107: error: call of overloaded 'class_id_type(intmax_t&)' is ambiguous
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp:118: note: candidates are: boost::archive::class_id_type::class_id_type(size_t)
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp:115: note:                 boost::archive::class_id_type::class_id_type(int)

3 个答案:

答案 0 :(得分:1)

并非真正直接回答您的问题,但我在Google的协议缓冲区方面取得了很大的成功。他们在内部使用它们并开源:http://code.google.com/p/protobuf/

答案 1 :(得分:0)

我用g ++ 4.1.2构建,它工作正常。我讨厌bjam,很难看到发生了什么,而且速度令人难以置信。 有一个关于弃用标题的警告,因为这有一个不赞成的朋友声明的标记,我希望看到一些旧的,但我没有。

您是使用bjam构建它还是尝试将序列化提取到您自己的目录中并自己完成?因为您的目录结构与包中的目录结构不完全相同。

答案 2 :(得分:0)

#define private public

应该摆脱关于访问私有成员的第一个错误。这有点厚脸皮!但它可以作为临时修复,直到你更好地理解整个程序。