Okay, there seems to be something wrong with my libboost installation. Or maybe I am stupid. How should i know?
[edit]Turns out I need to link to libboost_serialization when compiling…[/edit]
This is my source code, because what didn't work was becoming ridiculous:
#include <boost/archive/text_oarchive.hpp>
#include <iostream>
int main ( int argv, char * argc [ ] )
{
boost::archive::text_oarchive oa ( std::cout ) ;
int i = 1 ;
oa << i ;
}
This gives me the following barrage of errors:
/tmp/ccAXKj4K.o: In function `boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int)':
main.cpp:(.text._ZN5boost7archive13text_oarchiveC2ERSoj[_ZN5boost7archive13text_oarchiveC5ERSoj]+0x14): undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)'
/tmp/ccAXKj4K.o: In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED5Ev]+0x29): undefined reference to `boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'
/tmp/ccAXKj4K.o: In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
main.cpp:(.text._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED2Ev[_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED5Ev]+0x17): undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, int>(boost::archive::text_oarchive&, int const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveEiEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveEiEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/tmp/ccAXKj4K.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<int>(int const&)':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveIiEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveIiEEvRKT_]+0xe): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<int>(int const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_]+0x8c): undefined reference to `boost::archive::archive_exception::~archive_exception()'
/tmp/ccAXKj4K.o: In function `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)':
main.cpp:(.text._ZN5boost7archive17archive_exceptionC1ERKS1_[_ZN5boost7archive17archive_exceptionC1ERKS1_]+0x27): undefined reference to `vtable for boost::archive::archive_exception'
main.cpp:(.text._ZN5boost7archive17archive_exceptionC1ERKS1_[_ZN5boost7archive17archive_exceptionC1ERKS1_]+0x3b): undefined reference to `vtable for boost::archive::archive_exception'
/tmp/ccAXKj4K.o: In function `void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)':
main.cpp:(.text._ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_[_ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_]+0x2c): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_[_ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_]+0x31): undefined reference to `typeinfo for boost::archive::archive_exception'
/tmp/ccAXKj4K.o:(.rodata._ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE[_ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE]+0x10): undefined reference to `typeinfo for boost::archive::detail::basic_oarchive'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::version_type>(boost::archive::text_oarchive&, boost::archive::version_type const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_12version_typeEEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_12version_typeEEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::object_id_type>(boost::archive::text_oarchive&, boost::archive::object_id_type const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_14object_id_typeEEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_14object_id_typeEEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::object_reference_type>(boost::archive::text_oarchive&, boost::archive::object_reference_type const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_21object_reference_typeEEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_21object_reference_typeEEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::class_id_type>(boost::archive::text_oarchive&, boost::archive::class_id_type const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_13class_id_typeEEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_13class_id_typeEEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::class_id_reference_type>(boost::archive::text_oarchive&, boost::archive::class_id_reference_type const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_23class_id_reference_typeEEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_23class_id_reference_typeEEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/tmp/ccAXKj4K.o:main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_13tracking_typeEEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_13tracking_typeEEEvRT_RKT0_]+0xe): more undefined references to `boost::archive::detail::basic_oarchive::end_preamble()' follow
/tmp/ccAXKj4K.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_14object_id_typeEEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_14object_id_typeEEEvRKT_]+0xe): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
/tmp/ccAXKj4K.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_21object_reference_typeEEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_21object_reference_typeEEEvRKT_]+0xe): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
/tmp/ccAXKj4K.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_13class_id_typeEEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_13class_id_typeEEEvRKT_]+0xe): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
/tmp/ccAXKj4K.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_23class_id_reference_typeEEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_23class_id_reference_typeEEEvRKT_]+0xe): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
/tmp/ccAXKj4K.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_13tracking_typeEEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_13tracking_typeEEEvRKT_]+0xe): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
/tmp/ccAXKj4K.o:main.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveIjEEvRKT_[_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveIjEEvRKT_]+0xe): more undefined references to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()' follow
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_14object_id_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_14object_id_typeEEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_14object_id_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_14object_id_typeEEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_14object_id_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_14object_id_typeEEEvRKT_]+0x97): undefined reference to `boost::archive::archive_exception::~archive_exception()'
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_21object_reference_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_21object_reference_typeEEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_21object_reference_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_21object_reference_typeEEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_21object_reference_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_21object_reference_typeEEEvRKT_]+0x98): undefined reference to `boost::archive::archive_exception::~archive_exception()'
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13class_id_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13class_id_typeEEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13class_id_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13class_id_typeEEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13class_id_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13class_id_typeEEEvRKT_]+0x97): undefined reference to `boost::archive::archive_exception::~archive_exception()'
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_23class_id_reference_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_23class_id_reference_typeEEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_23class_id_reference_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_23class_id_reference_typeEEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_23class_id_reference_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_23class_id_reference_typeEEEvRKT_]+0x98): undefined reference to `boost::archive::archive_exception::~archive_exception()'
/tmp/ccAXKj4K.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::string>(boost::archive::text_oarchive&, std::string const&)':
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_]+0xe): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
main.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_[_ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_]+0x20): undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::string const&)'
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_]+0x98): undefined reference to `boost::archive::archive_exception::~archive_exception()'
/tmp/ccAXKj4K.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<unsigned int>(unsigned int const&)':
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_]+0x3b): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_]+0x5f): undefined reference to `boost::archive::archive_exception::~archive_exception()'
main.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_[_ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_]+0x8c): undefined reference to `boost::archive::archive_exception::~archive_exception()'
collect2: error: ld returned 1 exit status
Wat.