我一直在尝试使用boost::serialization
序列化一些对象。
请看下面的代码:
class Pedestal
{
typedef std::vector<double> DataVector;
public:
/** irrelevant functions */
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version) const
{
if(version >0){
ar & m_normalization;
ar & m_isNormalized;
ar & BOOST_SERIALIZATION_NVP(m_pedestals);
}
}
int m_normalization;
bool m_isNormalized;
DataVector m_pedestals;
另一个功能,就是试图将基座保存到文件中。
void PedestalCalculator::savePedestalToFile(const std::string& p_filename)
{
{
ofstream l_file(p_filename);
boost::archive::text_oarchive l_textArchive(l_file);
l_textArchive & m_pedestal;
}
}
gdb的输出:
你能告诉我我做错了什么吗?我花了很多时间阅读手册和调试,但我找不到解决方案。编程接收信号SIGSEGV,分段故障。
来自/usr/lib64/libboost_serialization.so.5的boost :: archive :: detail :: basic_oarchive :: save_object(void const *,boost :: archive :: detail :: basic_oserializer const&amp;)()中的0x00007fffde47397f < / p>
缺少单独的debuginfos,请使用:debuginfo-install boost-serialization-1.41.0-25.el6.x86_64 freetype-2.3.11-14.el6_3.1.x86_64 glibc-2.12-1.149.el6.x86_64 keyutils-libs -1.4-5.el6.x86_64 krb5-libs-1.10.3-33.el6.x86_64 libcom_err-1.41.12-21.el6.x86_64 libselinux-2.0.94-5.8.el6.x86_64 ncurses-libs-5.7-3.20090208 .el6.x86_64 nss-softokn-freebl-3.14.3-18.el6_6.x86_64 openssl-1.0.1e-30.el6_6.4.x86_64 readline-6.0-4.el6.x86_64 snoopy-1.7.10-1.el6 .x86_64 sssd-client-1.11.6-30.el6_6.3.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb)bt
来自/usr/lib64/libboost_serialization.so的boost :: archive :: detail :: basic_oarchive :: save_object(void const *,boost :: archive :: detail :: basic_oserializer const&amp;)()中的#0> 0x00007fffde47397f。 5 TbUT中的#1 0x00007fffde7266d3 :: PedestalCalculator :: savePedestalToFile(std :: basic_string,std :: allocator&gt; const&amp;)()
来自/afs/cern.ch/user/a/adendek/cmtuser/Kepler_v2r1/InstallArea/x86_64-slc6-gcc48-opt/lib/libTbUT.so