OpenCV中lib的添加

  环境 Visual Studio 2010 + OpenCV 2.3.1

  环境配置可参考下文http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=14545

  近来研究tracking相关问题,涉及到interest point的提取,应用到了"opencv2\features2d\features2d.hpp",然而,vs的IntelliSense没有报错,在编译的时候出现如下错误: 

错误    2    error LNK2019: 无法解析的外部符号 "public: __thiscall cv::SurfFeatureDetector::SurfFeatureDetector(double,int,int,bool)" (??0SurfFeatureDetector@cv@@QAE@NHH_N@Z),该符号在函数 _main 中被引用    E:\Coding\VS 2010\GroupBehaviour\Histogram\Histogram\Histogram.obj    Histogram

  这个错误的原因,我刚开始猜测是因为VS没有找到相应的定义,或者是根本就找不到"opencv2\features2d\features2d.hpp"中的SurfFeatureDetector,所以应该是配置问题,所以我搜了一些关于环境配置的内容,但都没有找到原因,最后在StackOverFlow上面
http://stackoverflow.com/questions/8272707/opencv-2-2-vs2010-get-an-access-violation-reading-in-a-very-simple-code  
看到一个回答

You need ensure that the following "Additional Dependencies" under the the Properties->Linker->Input are referring to the correct OpenCV libraries with debugger support.

i.e.

C:\OpenCV2.2\lib\opencv_calib3d220d.lib
C:\OpenCV2.2\lib\opencv_core220d.lib
C:\OpenCV2.2\lib\opencv_features2d220d.lib
-------------------
C:\OpenCV2.2\lib\opencv_highgui220d.lib
C:\OpenCV2.2\lib\opencv_imgproc220d.lib
instead of

C:\OpenCV2.2\lib\opencv_calib3d220.lib
C:\OpenCV2.2\lib\opencv_core220.lib
C:\OpenCV2.2\lib\opencv_features2d220.lib
C:\OpenCV2.2\lib\opencv_highgui220.lib
C:\OpenCV2.2\lib\opencv_imgproc220.lib

 我想,可能是我的lib没有添加,于是仔细看了一下之前的配置方法,发现几乎所有的配置中,添加的lib都是:

F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_core230d.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_highgui230d.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_video230d.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_ml230d.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_legacy230d.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_imgproc230d.lib



F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_core230.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_highgui230.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_video230.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_ml230.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_legacy230.lib
F:\Softs\OpenCV2.3\build\x86\vc10\lib\opencv_imgproc230.lib

  以上的只是常用lib,并不全,于是我找到自己电脑上的"...\opencv\vs2010\install\lib",发现这上面居然有26个,其中13个for debug,13个for release,而我们在上面只添加了6个for debug,6个for release,看来lib是针对性的添加,从而可以引用到相应的函数,按如上方法添加其它的lib即可。

  所有的lib如下所示:

For Release

opencv_calib3d231.lib
opencv_contrib231.lib
opencv_core231.lib
opencv_features2d231.lib
opencv_flann231.lib
opencv_gpu231.lib
opencv_highgui231.lib
opencv_imgproc231.lib
opencv_legacy231.lib
opencv_ml231.lib
opencv_objdetect231.lib
opencv_ts231.lib
opencv_video231.lib

For Debug

opencv_calib3d231d.lib
opencv_contrib231d.lib
opencv_core231d.lib
opencv_features2d231d.lib
opencv_flann231d.lib
opencv_gpu231d.lib
opencv_highgui231d.lib
opencv_imgproc231d.lib
opencv_legacy231d.lib
opencv_ml231d.lib
opencv_objdetect231d.lib
opencv_ts231d.lib
opencv_video231d.lib




你可能感兴趣的:(OpenCV中lib的添加)