Boost Serialization Beispiel kompilieren



  • Hallo,

    ich habe angefangen, mich mit der Serialization aus Boost zu befassen, und wollte zum Anfang die Beispiele aus dem Tutorial nachvollziehen. Schon der erste Code-Schnipsel lässt sich nicht kompilieren, sondern erschlägt mich mit (für mich) nicht nachvollziehbaren Reihen von Fehlern.

    Error-Log des Compilers:

    /tmp/ccIuIqsf.o: In function `boost::archive::text_oarchive::text_oarchive(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)':
    serial.cpp:(.text._ZN5boost7archive13text_oarchiveC1ERSoj[boost::archive::text_oarchive::text_oarchive(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)]+0x1b): undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)'
    /tmp/ccIuIqsf.o: In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x2c): undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x46): undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
    /tmp/ccIuIqsf.o: In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED1Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x2c): undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED1Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x46): undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
    /tmp/ccIuIqsf.o: In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED0Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x2c): undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
    /tmp/ccIuIqsf.o:serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED0Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x46): more undefined references to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()' follow
    /tmp/ccIuIqsf.o: In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
    serial.cpp:(.text._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED2Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()]+0x16): undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'
    /tmp/ccIuIqsf.o: In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
    serial.cpp:(.text._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED1Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()]+0x16): undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'
    /tmp/ccIuIqsf.o: In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
    serial.cpp:(.text._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED0Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()]+0x16): undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, int>(boost::archive::text_oarchive&, int const&)':
    serial.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveEiEEvRT_RKT0_[void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, int>(boost::archive::text_oarchive&, int const&)]+0xd): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<int>(int const&)':
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveIiEEvRKT_[void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<int>(int const&)]+0xd): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<int>(int const&)':
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<int>(int const&)]+0x49): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<int>(int const&)]+0x65): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIiEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<int>(int const&)]+0x7c): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    /tmp/ccIuIqsf.o: In function `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)':
    serial.cpp:(.text._ZN5boost7archive17archive_exceptionC1ERKS1_[boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)]+0x27): undefined reference to `vtable for boost::archive::archive_exception'
    serial.cpp:(.text._ZN5boost7archive17archive_exceptionC1ERKS1_[boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)]+0x3b): undefined reference to `vtable for boost::archive::archive_exception'
    /tmp/ccIuIqsf.o: In function `void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)':
    serial.cpp:(.text._ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_[void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)]+0x3e): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    serial.cpp:(.text._ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_[void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)]+0x46): undefined reference to `typeinfo for boost::archive::archive_exception'
    /tmp/ccIuIqsf.o:(.rodata._ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE[typeinfo for boost::archive::detail::common_oarchive<boost::archive::text_oarchive>]+0x10): undefined reference to `typeinfo for boost::archive::detail::basic_oarchive'
    /tmp/ccIuIqsf.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<unsigned int>(unsigned int const&)':
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveIjEEvRKT_[void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<unsigned int>(unsigned int const&)]+0xd): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)':
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)]+0x49): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)]+0x65): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveIjEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)]+0x7c): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::tracking_type>(boost::archive::text_oarchive&, boost::archive::tracking_type const&)':
    serial.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveENS0_13tracking_typeEEEvRT_RKT0_[void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::tracking_type>(boost::archive::text_oarchive&, boost::archive::tracking_type const&)]+0xd): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
    serial.cpp:(.text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEE4saveINS0_13tracking_typeEEEvRKT_[void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)]+0xd): undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, unsigned int>(boost::archive::text_oarchive&, unsigned int const&)':
    serial.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveEjEEvRT_RKT0_[void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, unsigned int>(boost::archive::text_oarchive&, unsigned int const&)]+0xd): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
    /tmp/ccIuIqsf.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
    serial.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_[void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0xd): undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
    serial.cpp:(.text._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_[void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x1f): undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    /tmp/ccIuIqsf.o: In function `void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)]+0x49): undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)]+0x65): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    serial.cpp:(.text._ZN5boost7archive21basic_text_oprimitiveISoE4saveINS0_13tracking_typeEEEvRKT_[void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)]+0x7c): undefined reference to `boost::archive::archive_exception::~archive_exception()'
    collect2: ld returned 1 exit status
    

    Compiler ist gcc aus dem Kubuntu Repository. Ein include Problem ist es nicht, ein einfaches boost-Programm aus dem Getting Started-Teil ließ sich kompilieren.

    Würde mich über eine Idee freuen

    Grüße
    brigg


  • Mod

    Das sind Linkerfehler. Hast du auch gegen die boost-serialization Bibliothek gelinkt?



  • Hast du die Biblitohek gebaut und zu deinem Projekt dazugelinkt? Anders als viele andere Boost-Bibltioheken besteht Boost.Serialization nämlich nicht nur aus headern.



  • Dankeschön! Ich habe zum Linken jetzt die Compiler-Option -lboost_serialization benutzt, ist das in Ordnung?

    Vielen Dank!



  • brigg schrieb:

    Dankeschön! Ich habe zum Linken jetzt die Compiler-Option -lboost_serialization benutzt, ist das in Ordnung?

    Vielen Dank!

    Das ist erstens eine Linker-Option, zweitens hängts vom Linker ab, ob das in Ordnung ist, und drittens kannst du das viel einfacher feststellen, als uns zu fragen - probiers doch einfach aus 😉


Log in to reply