opencv + VS2010 +win7 + 64位:
首先,opencv版本,vs版本,系统多少位都没关系。虽然系统是64位的,但是只要你想编写在32位上也可以跑的程序,那就按这个来就行。
1:环境变量
新建环境变量例如opencv,然后在path里加入 %opencv%\build\x86\vc10\bin; (不必包含X64,除非你要编译64位的程序,如果你有多个vs,也可以再添加上VC11.VC12什么的)
2:我是直接把所有的属性都配置了,就是属性管理器里面的Microsoft.Cpp.Win32.user这一项,debug下和release下的两个Win32.user其实是同一个文件,随便选一个配置,另一个就也变成一样的了。在这配的可以针对所有项目,相当于默认配置,只需一次,下次打开Vs永远不用重新配了。
3:VC++目录
包含目录:$(opencv)\build\include ; $(opencv)\build\include\opencv ; $(opencv)\build\include\opencv2 (记得将分号去掉)
库目录 :%opencv%\build\x86\vc10\lib (只需这一项就行,因为你要编写的是x86程序,不用考虑你的系统是64还是32)
4:链接器
附加依赖项:(我把debug和release两张都放进去了,不必单独地配置debug和release,因为你debug或者release时,vs会自动在这些库里寻找用到的那个库,所以放一块就行)
opencv_calib3d249d.lib
opencv_calib3d249.lib
opencv_contrib249d.lib
opencv_contrib249.lib
opencv_core249d.lib
opencv_core249.lib
opencv_features2d249d.lib
opencv_features2d249.lib
opencv_flann249d.lib
opencv_flann249.lib
opencv_gpu249d.lib
opencv_gpu249.lib
opencv_highgui249d.lib
opencv_highgui249.lib
opencv_imgproc249d.lib
opencv_imgproc249.lib
opencv_legacy249d.lib
opencv_legacy249.lib
opencv_ml249d.lib
opencv_ml249.lib
opencv_nonfree249d.lib
opencv_nonfree249.lib
opencv_objdetect249d.lib
opencv_objdetect249.lib
opencv_ocl249d.lib
opencv_ocl249.lib
opencv_photo249d.lib
opencv_photo249.lib
opencv_stitching249d.lib
opencv_stitching249.lib
opencv_superres249d.lib
opencv_superres249.lib
opencv_ts249d.lib
opencv_ts249.lib
opencv_video249d.lib
opencv_video249.lib
opencv_videostab249d.lib
opencv_videostab249.lib
5:release发布后:
你可以用dependency walker这个软件检查一下你的程序都用到了哪些opencv的dll,然后将这些dll拷到和程序同一个文件夹下,这样,这个文件夹拷到别的没装opencv的电脑上也可以运行了。
bingo!
自己的亲身经验。