请您帮我解决下面的问题?我试了3天没有成功。
问题在于我的序列化代码。每当我尝试实例化序列化时,我都会遇到此错误。
Can't load '/home/scratch.bipham_ctg100/generic_dev/scripts/x86_64-linux/auto/nDB/nDB.so' for module nDB: /home/scratch.bipham_ctg100/generic_dev/scripts/x86_64-linux/auto/nDB/nDB.so: undefined symbol: _ZTIN5boost7archive17archive_exceptionE at ...
以下是我写的代码
// nDB CONSTRUCTOR
//**********************
nDB::nDB() {
//_LAYERS = new boost::unordered_map<string,layer,myhash,cmp_str>;
}
// nDB DESTRUCTOR
//**********************
nDB::~nDB() {}
// nDB METHODS
//**********************
//===============================================================
// SERIALIZATION DEFINITION AND INITIALIZATION
template<class Archive>
void nDB::serialize(Archive &ar, const unsigned int version) {
boost::unordered_map<string,macro*,myhash,cmp_str>::const_iterator _ITER;
for (_ITER = _MACROS.begin();_ITER != _MACROS.end();_ITER++) {
ar & _ITER->first;
ar & *(_ITER->second);
}
}
//template void nDB::serialize<boost::archive::binary_oarchive>(
// boost::archive::binary_oarchive & ar,
// const unsigned int version
//);
//template void nDB::serialize<boost::archive::binary_iarchive>(
// boost::archive::binary_iarchive & ar,
// const unsigned int version
//);
//================================================================
void nDB::save_macros(string filename) {
std::ofstream ofs(filename.c_str(), std::ios::out | std::ios::binary);
boost::archive::binary_oarchive oa(ofs);
oa << *this;
}
答案 0 :(得分:0)
您需要链接boost序列化库。尝试将-lboost_serialization
添加到链接器标志。