我已经包含了这些头文件。
#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函数的未定义引用。
答案 0 :(得分:0)
尝试重新排序g++ coord.cpp -lboost_serialization -lboost_system