我在ExtractMaximalStableRegion.h
有两个班级。他们是
class ExtractM_StableRegion
{
public:
//! the full constructor
ExtractM_StableRegion(int _delta = 5, int _min_area = 60, int _max_area = 14400,
double _max_variation = 0.25, double _min_diversity = .2,
int _max_evolution = 200, double _area_threshold = 1.01,
double _min_margin = 0.003, int _edge_blur_size = 5);
//! the operator that extracts the MSERs from the image or the specific part of it
void operator()(const Mat& image, CV_OUT vector<vector<Point> >& msers, const Mat& mask = Mat());
//AlgorithmInfo* info() const;
protected:
int delta;
int minArea;
int maxArea;
double maxVariation;
double minDiversity;
int maxEvolution;
double areaThreshold;
double minMargin;
int edgeBlurSize;
};
另一个是
class ExtractM_StableRegion_ParallelProcess{
private:
vector<pair<Mat, Mat>> objs;
vector<vector<Point>> msers;
public:
~ExtractM_StableRegion_ParallelProcess(){
if (!objs.empty())
{
objs.clear();
vector<pair<Mat, Mat>>().swap(objs);//check these Mat is released
}
if (!objs.empty())
{
msers.clear();
vector<vector<Point> >().swap(msers);
}
}
void operator()(const tbb::blocked_range<tbb::size_t>& r) {
for (tbb::size_t i = r.begin(); i != r.end(); ++i)
{
ExtractM_StableRegion()(objs[i].first, msers, objs[i].second);
}
}
ExtractM_StableRegion_ParallelProcess(vector<pair<Mat, Mat>> objs_) : objs(objs_){}
ExtractM_StableRegion_ParallelProcess(ExtractM_StableRegion_ParallelProcess& x, tbb::split) : objs(x.objs), msers(x.msers){}
void join(ExtractM_StableRegion_ParallelProcess& y)
{
for (vector<vector<Point> >::iterator it = y.msers.begin(); it != y.msers.end(); ++it)
msers.push_back(*it);
vector< vector<Point> > local;//check local is released
ExtractM_StableRegion()(objs[0].first, local, objs[0].second);
}
void compareWithSingleThread(){
for (int i = 0; i < objs.size(); ++i)
{
vector< vector<Point> > local;//check local is released
ExtractM_StableRegion()(objs[i].first, local, objs[i].second);
for (vector<vector<Point> >::iterator it = local.begin(); it != local.end(); ++it)
msers.push_back(*it);
}
return;
}
vector<vector<Point> > getMSER_Regions(){
return msers;
}
};
ExtractM_StableRegion_ParallelProcess
是为ExtractM_StableRegion
课程加速使用TBB。
然后我有另一个cpp文件counting.cpp
并将ExtractM_StableRegion_ParallelProcess
类作为
ExtractM_StableRegion_ParallelProcess *ep = new ExtractM_StableRegion_ParallelProcess(objs);
//tbb::parallel_reduce(blocked_range<size_t>(0, numObj), *ep, auto_partitioner());//simple_partitioner()
ep->compareWithSingleThread();
当我构建时,我有链接器错误,我不理解为
Counting.obj : error LNK2019: unresolved external symbol "public: __cdecl VIDEOANALYTICS_PLATFORM::ExtractM_StableRegion::ExtractM_StableRegion(int,int,int,double,double,int,double,double,int)" (??0ExtractM_StableRegion@VIDEOANALYTICS_PLATFORM@@QEAA@HHHNNHNNH@Z) referenced in function "public: void __cdecl VIDEOANALYTICS_PLATFORM::ExtractM_StableRegion_ParallelProcess::compareWithSingleThread(void)" (?compareWithSingleThread@ExtractM_StableRegion_ParallelProcess@VIDEOANALYTICS_PLATFORM@@QEAAXXZ)
1>Counting.obj : error LNK2019: unresolved external symbol "public: void __cdecl VIDEOANALYTICS_PLATFORM::ExtractM_StableRegion::operator()(class cv::Mat const &,class std::vector<class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > >,class std::allocator<class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > > > &,class cv::Mat const &)" (??RExtractM_StableRegion@VIDEOANALYTICS_PLATFORM@@QEAAXAEBVMat@cv@@AEAV?$vector@V?$vector@V?$Point_@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@std@@V?$allocator@V?$vector@V?$Point_@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@std@@@2@@std@@0@Z) referenced in function "public: void __cdecl VIDEOANALYTICS_PLATFORM::ExtractM_StableRegion_ParallelProcess::compareWithSingleThread(void)" (?compareWithSingleThread@ExtractM_StableRegion_ParallelProcess@VIDEOANALYTICS_PLATFORM@@QEAAXXZ)
使用void compareWithSingleThread()
ExtractM_StableRegion()(objs[i].first, local, objs[i].second);
发生链接器错误
我还在ExtractM_StableRegion()(objs[i].first, local, objs[i].second);
方法中使用了对象void operator()(const tbb::blocked_range<tbb::size_t>& r)
。为什么compareWithSingleThread()
内的一个有错误而operator()
内没有错误。
感谢
答案 0 :(得分:1)
链接器错误意味着编译器已终止且没有错误但链接器无法为某些声明找到定义(函数,方法或符号) 。问题是,有时你必须猜测它来自何处。
在您的情况下,我会执行以下操作:减少您的示例。注释掉每个(成员)变量和方法体,除了错误消息中提到的那些。在上面的原始帖子中删除相应的行。这使得SO人员更容易理解出了什么问题。它甚至可能引导您找到解决方案。
将方法主体从.cpp文件移动到.h文件。这可能会暗示你出了什么问题。或者重建.cpp文件。
检查相应的项目属性或makefile或其他。某处必须指定 链接哪里和到和如何。这可能是不完整的。
您可以在Stackoverflow上找到其他提示,因为有许多关于链接器错误的问题,例如: this one