11

I need to (de)serialize data on both Windows and Linux (and transfer the files in between). I wanted to use the portable binary archives of Boost's serialization library which can be found in the examples, see e.g. at http://boost-doc-zh.googlecode.com/svn-history/r380/trunk/libs/serialization/example/

This works fine on Windows (VS 2008) but fails to compile under GCC 4.3.2 with the following errors.

Can anybody suggest a solution?

Thanks a lot!

/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)
Philipp
  • 11,549
  • 8
  • 66
  • 126

3 Answers3

1

Not really a direct answer to your question, but I've had a lot of success with Google's Protocol Buffers. They use them internally and open sourced them: http://code.google.com/p/protobuf/

Smokey.Canoe
  • 404
  • 2
  • 5
  • Thanks, but I know protobuf, and it doesn't fit nicely into my architecture. So I am looking for a Boost Serialization way to do it. – Philipp Apr 24 '11 at 05:35
0

I built with g++ 4.1.2 and it works fine. I hate bjam, it's hard to see what is happening, and it's unbelievably slow. There was a warning about a deprecated header, and since this has the earmarks of a deprecated friend declaration, I was hoping to see something old, but I don't.

Did you build it with bjam or did you try to pull out the serialization into your own directory and do it yourself? Because your directory structure is not exactly like the one they have in the package.

Dov
  • 8,000
  • 8
  • 46
  • 75
0
#define private public

ought to get rid of the first error about accessing private members. It's a bit cheeky! But it can work as a temporary fix until you've understood the whole program better.

Aaron McDaid
  • 26,501
  • 9
  • 66
  • 88
  • I think it's safe to do it. I've never done it myself, except to test that it works. Another way to do it is to just pass it on the command line to the compile `g++ -Dprivate=public prog.cpp -o prog`. Of course, it's your responsibility to ensure you deal with the private data correctly. But if you understand the internals of that class correctly, you should be able to interact with it in a sensible manner. – Aaron McDaid Jun 02 '11 at 11:03