Boost序列化编译错误



我正在使用netbeans开发一个使用boost serialization的简单c++程序。然而,当我试图编译程序时,我会遇到一堆异常和错误:

CLEAN SUCCESSFUL (total time: 203ms)
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/bernd/NetBeansProjects/LVAManager'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/lvamanager
make[2]: Entering directory `/home/bernd/NetBeansProjects/LVAManager'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/LVA.o.d
g++    -c -g -I/usr/include/boost -MMD -MP -MF build/Debug/GNU-Linux-x86/LVA.o.d -o build/Debug/GNU-Linux-x86/LVA.o LVA.cpp
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/Manager.o.d
g++    -c -g -I/usr/include/boost -MMD -MP -MF build/Debug/GNU-Linux-x86/Manager.o.d -o build/Debug/GNU-Linux-x86/Manager.o Manager.cpp
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++    -c -g -I/usr/include/boost -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/lvamanager build/Debug/GNU-Linux-x86/LVA.o build/Debug/GNU-Linux-x86/Manager.o build/Debug/GNU-Linux-x86/main.o 
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int)':
/usr/include/boost/archive/text_oarchive.hpp:100: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
/usr/include/boost/archive/text_oarchive.hpp:85: undefined reference to `boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'
/usr/include/boost/archive/text_oarchive.hpp:85: undefined reference to `boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
/usr/include/boost/archive/detail/common_oarchive.hpp:35: undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()'
build/Debug/GNU-Linux-x86/main.o:(.rodata._ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE[_ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE]+0x18): undefined reference to `typeinfo for boost::archive::detail::basic_oarchive'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
build/Debug/GNU-Linux-x86/main.o:/usr/include/boost/archive/detail/oserializer.hpp:87: more undefined references to `boost::archive::detail::basic_oarchive::end_preamble()' follow
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
/usr/include/boost/archive/text_oarchive.hpp:60: undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()'
build/Debug/GNU-Linux-x86/main.o:/usr/include/boost/archive/text_oarchive.hpp:60: more undefined references to `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::newtoken()' follow
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::object_id_type>(boost::archive::object_id_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::object_reference_type>(boost::archive::object_reference_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::class_id_type>(boost::archive::class_id_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.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&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::string>(boost::archive::text_oarchive&, std::string const&)':
/usr/include/boost/archive/detail/oserializer.hpp:87: undefined reference to `boost::archive::detail::basic_oarchive::end_preamble()'
/usr/include/boost/archive/detail/oserializer.hpp:88: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::string const&)'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<boost::archive::tracking_type>(boost::archive::tracking_type const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::archive::basic_text_oprimitive<std::ostream>::save<unsigned int>(unsigned int const&)':
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception::exception_code, char const*, char const*)'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/archive/basic_text_oprimitive.hpp:91: undefined reference to `boost::archive::archive_exception::~archive_exception()'
build/Debug/GNU-Linux-x86/main.o: In function `boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&)':
/usr/include/boost/archive/archive_exception.hpp:43: undefined reference to `vtable for boost::archive::archive_exception'
/usr/include/boost/archive/archive_exception.hpp:43: undefined reference to `vtable for boost::archive::archive_exception'
build/Debug/GNU-Linux-x86/main.o: In function `void boost::serialization::throw_exception<boost::archive::archive_exception>(boost::archive::archive_exception const&)':
/usr/include/boost/serialization/throw_exception.hpp:36: undefined reference to `boost::archive::archive_exception::~archive_exception()'
/usr/include/boost/serialization/throw_exception.hpp:36: undefined reference to `typeinfo for boost::archive::archive_exception'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/lvamanager] Error 1
make[2]: Leaving directory `/home/bernd/NetBeansProjects/LVAManager'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/bernd/NetBeansProjects/LVAManager'
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)

我读到boost serialization不是只有头的库。这和这个有关系吗?Netbeans知道boost库,并为我提供代码帮助等。但我是否需要链接它?

如何链接Netbeans中的库?我在哪里能找到它。我安装了debian系统和libboost-all-dev

您需要将-lboost_serialization添加到链接器命令中
我已经很久没有使用netbeans了,但据我记忆所及,它类似于Build->Linker->Libraries
你不需要添加-l,我认为netbeans可以为你做到这一点。

相关内容

  • 没有找到相关文章