0

I am working on my assignment in which I think I can use boost.serialization library. But we are asked to use only header only version of boost. So I want to know wheather boost.serialization fall under header only version or not?

  • 1
    For a header only library you only need `#include` staments to use it, without any need to link against a binary part of the library and without adding file of that library as compilation unit. A library can be partilly include only. – t.niese Oct 02 '22 at 19:48
  • 1
    So if your compiled binary works without linking against boost (and any other library), then at least the part you use is header only. – t.niese Oct 02 '22 at 19:50
  • Does this answer your question? [Which Boost libraries are header-only?](https://stackoverflow.com/questions/13604090/which-boost-libraries-are-header-only) (For the curious: my search of this site was for `[boost] header only`.) – JaMiT Oct 03 '22 at 01:20

1 Answers1

1

No, it requires linking with the boost_serialization or boost_wserialization library.

Failing to link with the library will for the most basic demo on the boost site produce a long list of undefined references:

undefined reference to...
`boost::archive::archive_exception::~archive_exception()'
`boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)'
`boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
`boost::archive::basic_text_iprimitive<std::istream>::~basic_text_iprimitive()'
`boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::init()'
`boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
`boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'
`boost::archive::detail::basic_iarchive::~basic_iarchive()'
`boost::archive::detail::basic_iarchive::load_object(void*, boost::archive::detail::basic_iserializer const&)'
`boost::archive::detail::basic_iserializer::~basic_iserializer()'
`boost::archive::detail::basic_iserializer::basic_iserializer(boost::serialization::extended_type_info const&)'
`boost::archive::detail::basic_oarchive::~basic_oarchive()'
`boost::archive::detail::basic_oarchive::end_preamble()'
`boost::archive::detail::basic_oarchive::save_object(void const*, boost::archive::detail::basic_oserializer const&)'
`boost::archive::detail::basic_oserializer::~basic_oserializer()'
`boost::archive::detail::basic_oserializer::basic_oserializer(boost::serialization::extended_type_info const&)'
`boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::init()'
`boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::load_override(boost::archive::class_name_type&)'
`boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::text_iarchive_impl(std::istream&, unsigned int)'
`boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
`boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)'
`boost::serialization::extended_type_info::key_register() const'
`boost::serialization::extended_type_info::key_unregister() const'
`boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0()'
`boost::serialization::typeid_system::extended_type_info_typeid_0::extended_type_info_typeid_0(char const*)'
`boost::serialization::typeid_system::extended_type_info_typeid_0::is_equal(boost::serialization::extended_type_info const&) const'
`boost::serialization::typeid_system::extended_type_info_typeid_0::is_less_than(boost::serialization::extended_type_info const&) const'
`boost::serialization::typeid_system::extended_type_info_typeid_0::type_register(std::type_info const&)'
`boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()'
`typeinfo for boost::archive::archive_exception'
`typeinfo for boost::archive::detail::basic_iarchive'
`typeinfo for boost::archive::detail::basic_iserializer'
`typeinfo for boost::archive::detail::basic_oarchive'
`typeinfo for boost::archive::detail::basic_oserializer'
`typeinfo for boost::serialization::typeid_system::extended_type_info_typeid_0'
Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • thanks but can you show any proof ? and are you saying I cannot use it? – petrik_hayden Oct 02 '22 at 19:42
  • @petrik_hayden Just copy a program from their tutorial or [the demo](https://www.boost.org/doc/libs/release/libs/serialization/example/demo.cpp) and try to compile it without linking with `boost_serialization` – Ted Lyngmo Oct 02 '22 at 19:49
  • you mean in [demo](https://www.boost.org/doc/libs/1_80_0/libs/serialization/example/demo.cpp) , #include is neccessary to compile the program – petrik_hayden Oct 02 '22 at 20:00
  • @petrik_hayden I mean it's necessary to link with the `boost_serialization` library if you want to get a runable program from it. – Ted Lyngmo Oct 02 '22 at 20:01