Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flann functions unresolved externals

Tags:

opencv

I'm trying to run one of the tutorial examples from OpenCV. It is about finding a known object with use of Flann based key point matching. Code can be found on Features2D + Homography to find a known object.

I know you will ask "Did you link the libraries?" or similar question. Yes I have been using OpenCV for 3 weeks with various examples which make use of nearly all libraries. And there was no problem until this day.

So I added these library dependecies to Visual Studio's linker input settings. Include directories are also working fine.

C:\OpenCV2.4\lib\opencv_core242d.lib
C:\OpenCV2.4\lib\opencv_highgui242d.lib
C:\OpenCV2.4\lib\opencv_video242d.lib
C:\OpenCV2.4\lib\opencv_ml242d.lib
C:\OpenCV2.4\lib\opencv_legacy242d.lib
C:\OpenCV2.4\lib\opencv_imgproc242d.lib
C:\OpenCV2.4\lib\opencv_objdetect242d.lib
C:\OpenCV2.4\lib\opencv_flann242d.lib
C:\OpenCV2.4\lib\opencv_nonfree242d.lib
C:\OpenCV2.4\lib\opencv_calib3d242d.lib

The error I got is a linker error. It can't resolve Flann's functions.

1>------ Build started: Project: flannMatch, Configuration: Debug Win32 ------
1>flannMatch.obj : error LNK2019: unresolved external symbol "void __cdecl cv::drawMatches(class cv::Mat const &,class std::vector<class cv::KeyPoint,class std::allocator<class cv::KeyPoint> > const &,class cv::Mat const &,class std::vector<class cv::KeyPoint,class std::allocator<class cv::KeyPoint> > const &,class std::vector<struct cv::DMatch,class std::allocator<struct cv::DMatch> > const &,class cv::Mat &,class cv::Scalar_<double> const &,class cv::Scalar_<double> const &,class std::vector<char,class std::allocator<char> > const &,int)" (?drawMatches@cv@@YAXABVMat@1@ABV?$vector@VKeyPoint@cv@@V?$allocator@VKeyPoint@cv@@@std@@@std@@01ABV?$vector@UDMatch@cv@@V?$allocator@UDMatch@cv@@@std@@@4@AAV21@ABV?$Scalar_@N@1@4ABV?$vector@DV?$allocator@D@std@@@4@H@Z) referenced in function _main
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::DescriptorMatcher::match(class cv::Mat const &,class cv::Mat const &,class std::vector<struct cv::DMatch,class std::allocator<struct cv::DMatch> > &,class cv::Mat const &)const " (?match@DescriptorMatcher@cv@@QBEXABVMat@2@0AAV?$vector@UDMatch@cv@@V?$allocator@UDMatch@cv@@@std@@@std@@0@Z) referenced in function_main
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::FlannBasedMatcher::FlannBasedMatcher(class cv::Ptr<struct cv::flann::IndexParams> const &,class cv::Ptr<struct cv::flann::SearchParams> const &)" (??0FlannBasedMatcher@cv@@QAE@ABV?$Ptr@UIndexParams@flann@cv@@@1@ABV?$Ptr@USearchParams@flann@cv@@@1@@Z) referenced in function _main
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::DescriptorExtractor::compute(class cv::Mat const &,class std::vector<class cv::KeyPoint,class std::allocator<class cv::KeyPoint> > &,class cv::Mat &)const " (?compute@DescriptorExtractor@cv@@QBEXABVMat@2@AAV?$vector@VKeyPoint@cv@@V?$allocator@VKeyPoint@cv@@@std@@@std@@AAV32@@Z) referenced in function _main
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::FeatureDetector::detect(class cv::Mat const &,class std::vector<class cv::KeyPoint,class std::allocator<class cv::KeyPoint> > &,class cv::Mat const &)const " (?detect@FeatureDetector@cv@@QBEXABVMat@2@AAV?$vector@VKeyPoint@cv@@V?$allocator@VKeyPoint@cv@@@std@@@std@@0@Z) referenced in function _main
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::DescriptorMatcher::~DescriptorMatcher(void)" (??1DescriptorMatcher@cv@@UAE@XZ) referenced in function "public: virtual __thiscall cv::FlannBasedMatcher::~FlannBasedMatcher(void)" (??1FlannBasedMatcher@cv@@UAE@XZ)
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::DescriptorMatcher::DescriptorCollection::~DescriptorCollection(void)" (??1DescriptorCollection@DescriptorMatcher@cv@@UAE@XZ) referenced in function "public: virtual __thiscall cv::FlannBasedMatcher::~FlannBasedMatcher(void)" (??1FlannBasedMatcher@cv@@UAE@XZ)
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::FeatureDetector::~FeatureDetector(void)" (??1FeatureDetector@cv@@UAE@XZ) referenced in function "public: virtual __thiscall cv::Feature2D::~Feature2D(void)" (??1Feature2D@cv@@UAE@XZ)
1>flannMatch.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::DescriptorExtractor::~DescriptorExtractor(void)" (??1DescriptorExtractor@cv@@UAE@XZ) referenced in function "public: virtual __thiscall cv::Feature2D::~Feature2D(void)" (??1Feature2D@cv@@UAE@XZ)

I also know that surf and sift was moved to nonfree, thanks to one of questions here. At first glance I thought it may be because I have two version of OpenCV (2.2 and 2.4) and thus it was making a difference. So I removed 2.2 and tried to run another program. It was working fine but still this error was not gone.

So my question, what am I missing here? Is there another library dependency? What is it that I can't see? Any help is appreciated.

--EDIT--

How could I not see it? I'm really sorry for posting an easy question like this. I feel so stupid. I had forgotten to add this dependency.

C:\OpenCV2.4\lib\opencv_features2d242d.lib

I dont think anybody would miss that again.

like image 882
yutasrobot Avatar asked Aug 28 '12 10:08

yutasrobot


People also ask

How do I fix unresolved external symbol?

So when we try to assign it a value in the main function, the linker doesn't find the symbol and may result in an “unresolved external symbol” or “undefined reference”. The way to fix this error is to explicitly scope the variable using '::' outside the main before using it.

What does unresolved externals mean?

Unresolved external references occur when the symbol for a function or global variable is referenced in a program, but none of the object files or libraries specified in the link step contain a definition for that symbol.

What is an unresolved external symbol in C++?

So, as a result - an "undefined reference/unresolved external symbol error" happens when the linker cannot find global symbols in the object files.


1 Answers

How could i not see it? I m really sorry for posting an easy question like this. I feel so stupid. I had forgotten to add this dependecy.

C:\OpenCV2.4\lib\opencv_features2d242d.lib

I dont think anybody would miss that again.

like image 180
yutasrobot Avatar answered Sep 25 '22 10:09

yutasrobot