c ++:无法实现boost :: archive :: text_oarchive或boost :: archive :: binary_oarchive

时间:2014-11-14 10:18:08

标签: c++ c++11 serialization boost

我这里有一段很短的代码,不会起作用。

我认为我完全按照文档的步骤进行操作..但我无法理解这一点,为什么我的代码无效:

#include <gtest/gtest.h>
#include <cstdint>
#include <fstream>
#include <boost/archive/text_oarchive.hpp>


TEST(HeaderField2, test2){
std::ofstream ofs("test");
boost::archive::text_oarchive oa(ofs);
oa << "test";
}

错误消息如下:

serialize.cpp :(。text._ZN5boost7archive13text_oarchiveC2ERSoj [_ZN5boost7archive13text_oarchiveC5ERSoj] + 0x25):Nicht definierter Verweis auf boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)' CMakeFiles/GTest_Serialize.dir/serialize.cpp.o: In Funktion boost :: archive :: text_oarchive_impl :: ~text_oarchive_impl()': serialize.cpp :(。text._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev [_ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED5Ev] + 0x2f):Nicht definierter Verweis auf boost::archive::basic_text_oprimitive<std::ostream>::~basic_text_oprimitive()' CMakeFiles/GTest_Serialize.dir/serialize.cpp.o: In Funktion boost :: archive :: detail :: common_oarchive :: ~common_oarchive()': serialize.cpp :(。text._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED2Ev [_ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED5Ev] +0x1f):Nicht definierter Verweis auf boost::archive::detail::basic_oarchive::~basic_oarchive()' CMakeFiles/GTest_Serialize.dir/serialize.cpp.o: In Funktion void boost :: archive :: save_access :: end_preamble(boost :: archive :: text_oarchive&amp;)': serialize.cpp :(。text._ZN5boost7archive11save_access12end_preambleINS0_13text_oarchiveEEEvRT _ [_ ZN5boost7archive11save_access12end_preambleINS0_13text_oarchiveEEEvRT _] + 0x14):Nicht definierter Verweis auf boost::archive::detail::basic_oarchive::end_preamble()' CMakeFiles/GTest_Serialize.dir/serialize.cpp.o: In Funktion void boost :: archive :: save_access :: save_primitive(boost :: archive :: text_oarchive&amp;,boost :: serialization :: collection_size_type const&amp;)':

有人可以解释一下,错误来自何处?

0 个答案:

没有答案