如何在VS2013下配置OpenCV VS2013+opencv2.4.10配置 vs2013配置opencv
VS2013怎么配置opencv才能不用每次都重新配置一遍
我们平时在VS2013上借用opencv的函数时,很多时候都是以动态链接的方式调用opencv的库函数,以至于脱离了你的电脑到别的电脑上(没装opencv或装了opencv但版本跟你的不一样)运行时,运行不了,这是没有以静态链接的方式!!!!!
注意以下是建立在 在系统环境变量配置好后
步骤1: 右击我的电脑 选择 属性 在点击 高级系统设置 在点击环境变量
自己在用户变量那里新建两个变量 如下图, 变量值如下 当然路径是你自己的
注意 系统变量值后面要加 ; 即英文的分号
后面就可以开始配置静态链接库了
今天下午花了半下午的时间才将自己的电脑配好,网上的教程主要也没说清楚,自己照着原版的配置或多或少遇到问题:
1、Error 1 error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in bvpmeasure.obj
2、 error LNK2019: 无法解析的外部符号 __imp__GetFocus@0,该符号在函数 _Win32WarningHandler 中被引用
error LNK2019: 无法解析的外部符号_imp__MessageBoxA@16,该符号在函数 _WinMain@16 中被引用
1类下面还有很多错误,解决办法:
步骤一:VS2013中 菜单栏-》视图 选择 属性管理器 打开以下界面 在Microsoft.CPP.Win32.user上右击 选择属性,把附加依赖项清掉原来opencv的链接库
下面是添加静态库!!!!!
运行库的几种选择:Multi-threaded (/MT) 静态release Multi-threaded Debug (/MTd) 静态debug Multi-threaded DLL (/MD) 动态release Multi-threaded Debug DLL (/MDd) 动态debug
一定要注意debug 和 relase下面最好都要改 成配套的
2类下面还有很多错误,解决办法:
步骤一:
自己添加一个头文件,最后包含到相应的cpp中,头文件中添加 #pragma comment(lib,"User32.lib")
如果还是有错误 添加//#pragma comment( lib, "vfw32.lib" )
//#pragma comment( lib, "comctl32.lib" ) //这两条代码我添加后错误没解决,添加#pragma comment(lib,"User32.lib") 这个解决了
总体来说 只有自己建立个头文件,包含以下命令,就差不多了
[html] view plain copy
- #include <cvaux.h>
- #include <cxcore.h>
- #include <highgui.h> //头文件按照自己需要添加
[html] view plain copy
- #ifdef _DEBUG
- #pragma comment( lib, "IlmImfd.lib")
- #pragma comment( lib, "libjasperd.lib")
- #pragma comment( lib, "libjpegd.lib")
- #pragma comment( lib, "libpngd.lib")
- #pragma comment( lib, "libtiffd.lib")
- #pragma comment( lib, "zlibd.lib")
-
- #pragma comment( lib, "opencv_calib3d2410d.lib" )
- #pragma comment( lib, "opencv_contrib2410d.lib" )
- #pragma comment( lib, "opencv_core2410d.lib" )
- #pragma comment( lib, "opencv_features2d2410d.lib" )
- #pragma comment( lib, "opencv_flann2410d.lib" )
- #pragma comment( lib, "opencv_gpu2410d.lib" )
- #pragma comment( lib, "opencv_highgui2410d.lib" )
- #pragma comment( lib, "opencv_imgproc2410d.lib" )
- #pragma comment( lib, "opencv_legacy2410d.lib" )
- #pragma comment( lib, "opencv_ml2410d.lib" )
- #pragma comment( lib, "opencv_nonfree2410d.lib" )
- #pragma comment( lib, "opencv_objdetect2410d.lib" )
- #pragma comment( lib, "opencv_ocl2410d.lib" )
- #pragma comment( lib, "opencv_photo2410d.lib" )
- #pragma comment( lib, "opencv_stitching2410d.lib" )
- #pragma comment( lib, "opencv_superres2410d.lib" )
- #pragma comment( lib, "opencv_ts2410d.lib" )
- #pragma comment( lib, "opencv_video2410d.lib" )
- #pragma comment( lib, "opencv_videostab2410d.lib" )
- #else
- #pragma comment( lib, "IlmImf.lib")
- #pragma comment( lib, "libjasper.lib")
- #pragma comment( lib, "libjpeg.lib")
- #pragma comment( lib, "libpng.lib")
- #pragma comment( lib, "libtiff.lib")
- #pragma comment( lib, "zlib.lib")
- #pragma comment( lib, "opencv_calib3d2410.lib" )
- #pragma comment( lib, "opencv_contrib2410.lib" )
- #pragma comment( lib, "opencv_core2410.lib" )
- #pragma comment( lib, "opencv_features2d2410.lib" )
- #pragma comment( lib, "opencv_flann2410.lib" )
- #pragma comment( lib, "opencv_gpu2410.lib" )
- #pragma comment( lib, "opencv_highgui2410.lib" )
- #pragma comment( lib, "opencv_imgproc2410.lib" )
- #pragma comment( lib, "opencv_legacy2410.lib" )
- #pragma comment( lib, "opencv_ml2410.lib" )
- #pragma comment( lib, "opencv_nonfree2410.lib" )
- #pragma comment( lib, "opencv_objdetect2410.lib" )
- #pragma comment( lib, "opencv_ocl2410.lib" )
- #pragma comment( lib, "opencv_photo2410.lib" )
- #pragma comment( lib, "opencv_stitching2410.lib" )
- #pragma comment( lib, "opencv_superres2410.lib" )
- #pragma comment( lib, "opencv_ts2410.lib" )
- #pragma comment( lib, "opencv_video2410.lib" )
- #pragma comment( lib, "opencv_videostab2410.lib" )
- #endif
-
- #pragma comment( lib, "User32.lib")
- #pragma comment( lib, "gdi32.lib")
- #pragma comment( lib, "vfw32.lib" )
- #pragma comment( lib, "comctl32.lib" )
- #pragma comment( lib, "AdvAPI32.lib" )
- #pragma comment( lib, "ole32.lib" )
- #pragma comment( lib, "advapi32.lib")
- #pragma comment( lib, "oleaut32.lib")
-
- using namespace cv;
[html] view plain copy
-
dir *2410.lib /ON /B > libddd.txt
总体来说 只有自己建立个头文件,包含以下命令,就差不多了