Boost序列化中的编译错误,未定义参考

时间:2019-01-18 16:21:10

标签: c++ serialization boost

我已经包含了这些头文件。

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/vector.hpp>

然后我有两行:

ofstream s_dict("save_dict.archive");
boost::archive::text_oarchive oa_dict(s_dict);

编译时:

g++ -lboost_serialization -lboost_system coord.cpp

它会抛出一长串错误,其中第一个错误是

/tmp/ccRMDC8f.o:在函数boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int)': coord.cpp:(.text._ZN5boost7archive13text_oarchiveC2ERSoj[_ZN5boost7archive13text_oarchiveC5ERSoj]+0x25): undefined reference to boost :: archive :: text_oarchive_impl :: text_oarchive_impl(std :: ostream&,unsigned int)'

它正在获得对Boost函数的未定义引用。

1 个答案:

答案 0 :(得分:0)

尝试重新排序g++ coord.cpp -lboost_serialization -lboost_system