我有一个链接到两个已编译库的c ++项目。 libs基于我修改为同时运行的相同代码。但是,这两个库都使用boost::serialization
,因此它们都具有以下功能:
·H
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
boost::serialization::split_member(ar, *this, version);
}
template<class Archive>
void save(Archive & ar, const unsigned int version) const;
template<class Archive>
void load(Archive & ar, const unsigned int version);
当我尝试编译链接了两个库的项目时,我得到:
d:\include\mMapPoint.h(190): error C2995: 'void boost::serialization::serialize(Archive &,cv::Mat &,const unsigned int)': function template has already been defined
d:\include\MapPoint.h(192): note: see declaration of 'boost::serialization::serialize'
d:\include\mMapPoint.h(207): error C2995: 'void boost::serialization::serialize(Archive &,cv::KeyPoint &,const unsigned int)': function template has already been defined
d:\include\MapPoint.h(199): note: see declaration of 'boost::serialization::serialize'
d:\include\mMapPoint.h(227): error C2995: 'void boost::serialization::save(Archive &,const cv::Mat &,const unsigned int)': function template has already been defined
d:\include\MapPoint.h(216): note: see declaration of 'boost::serialization::save'
d:\include\mMapPoint.h(245): error C2995: 'void boost::serialization::load(Archive &,cv::Mat &,const unsigned int)': function template has already been defined
d:\include\MapPoint.h(233): note: see declaration of 'boost::serialization::load'
mMapPoint.h
中提到的行是:
BOOST_SERIALIZATION_SPLIT_FREE(::cv::Mat) //line 190
namespace boost {
namespace serialization {
/*** CV mKeyFrame ***/
template<class Archive>
void serialize(Archive & ar, cv::KeyPoint & kf, const unsigned int version)
{
ar & kf.angle;
ar & kf.class_id;
ar & kf.octave;
ar & kf.response;
ar & kf.response;
ar & kf.pt.x;
ar & kf.pt.y;
} //line 207
/*** Mat ***/
/** Serialization support for cv::Mat */
template<class Archive>
void save(Archive & ar, const ::cv::Mat& m, const unsigned int version)
{
size_t elem_size = m.elemSize();
size_t elem_type = m.type();
ar & m.cols;
ar & m.rows;
ar & elem_size;
ar & elem_type;
const size_t data_size = m.cols * m.rows * elem_size;
ar & boost::serialization::make_array(m.ptr(), data_size);
}//line 227
/** Serialization support for cv::Mat */
template<class Archive>
void load(Archive & ar, ::cv::Mat& m, const unsigned int version)
{
int cols, rows;
size_t elem_size, elem_type;
ar & cols;
ar & rows;
ar & elem_size;
ar & elem_type;
m.create(rows, cols, elem_type);
size_t data_size = m.cols * m.rows * elem_size;
ar & boost::serialization::make_array(m.ptr(), data_size);
}//line 245
我认为这是因为名称在两个库中都匹配。
我已经尝试在其中一个库中重命名这些函数(msave
,mload
和mserialize
),但是获得了一个提升错误:
\boost/serialization/split_free.hpp(58): error C2672: 'load': no matching overloaded function found
如何同时运行两个同时调用这些boost函数的库?谢谢。