ブーストライブラリを使用してプログラム内のオブジェクトをシリアル化したいとします。それは私が初めてそれを使用していると私にいくつかの問題を与えています。ブーストのシリアライゼーション:ライブラリへのリンク
私は「シリアライズ」メソッドを実装し、次のものが含まれている私のプログラムで:
#include <fstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
今、私はビルドするとき、私は次のエラーを取得:
Undefined symbols for architecture x86_64:
"boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)", referenced from:
boost::archive::text_oarchive::text_oarchive(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)in Main.o
"boost::archive::detail::basic_oarchive::~basic_oarchive()", referenced from:
boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()in Main.o
boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()in Main.o
boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()in Main.o
"boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()", referenced from:
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()in Main.o
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()in Main.o
boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()in Main.o
"vtable for boost::archive::archive_exception", referenced from:
boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)in Main.o
"typeinfo for boost::archive::archive_exception", referenced from:
void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)in Main.o
"boost::archive::archive_exception::~archive_exception()", referenced from:
void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)in Main.o
...
"boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)", referenced from:
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<unsigned int>(unsigned int const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)in Main.o
"boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()", referenced from:
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<unsigned int>(unsigned int const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_reference_type>(boost::archive::class_id_reference_type const&)in Main.o
void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)in Main.o
"boost::archive::detail::basic_oarchive::end_preamble()", referenced from:
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::tracking_type>(boost::archive::text_oarchive&, boost::archive::tracking_type const&)in Main.o
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&)in Main.o
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&)in Main.o
void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, boost::archive::version_type>(boost::archive::text_oarchive&, boost::archive::version_type const&)in Main.o
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&)in Main.o
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&)in Main.o
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&)in Main.o
...
"boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
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&)in Main.o
"typeinfo for boost::archive::detail::basic_oarchive", referenced from:
typeinfo for boost::archive::detail::common_oarchive<boost::archive::text_oarchive>in Main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [stable] Error 1
場合、私はわかりません問題はリンクのためか、64ビットと32ビットのアーキテクチャと関係がある場合です。
私はとのリンクを試してみました:
-L/opt/local/lib/ -lboost_iostreams -lboost_serialization
しかし、何の違いを行うにはいないようです。