要想将使用了OpenCV的程序运行在没有安装OpenCV的电脑上,需要将OpenCV的动态链接库(DLL)或静态链接库(LIB)进行打包,本文讲解使用静态链接库的方法。通过本文的方法,可以在VS2013生成的程序中自动打包所需的OpenCV库,可以让程序运行在没有安装OpenCV的电脑上。
修改VC++目录
通用属性->VC++目录->包含目录填入一下三行:
D:\library\opencv2413\build\include
D:\library\opencv2413\build\include\opencv
D:\library\opencv2413\build\include\opencv2
VC++目录->库目录,填入:
D:\library\opencv2413\build\x86\vc12\staticlib
不要使用D:\library\opencv2413\build\x86\vc12\lib
代码生成方式
通用属性->C/C++->代码生成->运行库选择“多线程调试 (/MTd)”
release模式下选择“多线程调试 (/MT)”
附加依赖项
通用属性->连接器->输入->附加依赖项,填入:
vfw32.lib
comctl32.lib
zlibd.lib
libjasperd.lib
libjpegd.lib
libpngd.lib
libtiffd.lib
IlmImfd.lib
opencv_core2413d.lib
opencv_imgproc2413d.lib
opencv_highgui2413d.lib
opencv_ml2413d.lib
opencv_video2413d.lib
opencv_features2d2413d.lib
opencv_calib3d2413d.lib
opencv_objdetect2413d.lib
opencv_contrib2413d.lib
opencv_legacy2413d.lib
opencv_flann2413d.lib
release模式下填:
vfw32.lib
comctl32.lib
zlib.lib
libjasper.lib
libjpeg.lib
libpng.lib
libtiff.lib
IlmImf.lib
opencv_core2413.lib
opencv_imgproc2413.lib
opencv_highgui2413.lib
opencv_ml2413.lib
opencv_video2413.lib
opencv_features2d2413.lib
opencv_calib3d2413.lib
opencv_objdetect2413.lib
opencv_contrib2413.lib
opencv_legacy2413.lib
opencv_flann2413.lib