visual studio静态以及动态链接opencv库

以vs2012和opencv2.4.11为例

动态链接:

其他平台不一定能正常运行,需要将DLL复制到exe目录下。

1)配置属性—VC++目录—包含目录

D:\OpenCV-x64\include
D:\OpenCV-x64\include\opencv
D:\OpenCV-x64\include\opencv2

2)配置属性—VC++目录—库目录

D:\OpenCV-x64\lib

3)通用配置—链接器—输入—附加依赖项

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
opencv_core2411d.lib
opencv_highgui2411d.lib
opencv_imgproc2411d.lib
opencv_calib3d2411d.lib
opencv_legacy2411d.lib
opencv_ml2411d.lib
opencv_objdetect2411d.lib
opencv_video2411d.lib

静态链接:

生成的程序会大很多,可以直接在其他平台运行。

1)配置属性—VC++目录—包含目录

D:\OpenCV-x64\include
D:\OpenCV-x64\include\opencv
D:\OpenCV-x64\include\opencv2

2)配置属性—VC++目录—库目录

D:\OpenCV-x64\staticlib

3)通用配置—链接器—输入—附加依赖项

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
IlmImf.lib
libjasper.lib
libjpeg.lib
libpng.lib
libtiff.lib
zlib.lib
opencv_calib3d2411.lib
opencv_contrib2411.lib
opencv_core2411.lib
opencv_features2d2411.lib
opencv_flann2411.lib
opencv_gpu2411.lib
opencv_highgui2411.lib
opencv_imgproc2411.lib
opencv_legacy2411.lib
opencv_ml2411.lib
opencv_nonfree2411.lib
opencv_objdetect2411.lib
opencv_ocl2411.lib
opencv_photo2411.lib
opencv_stitching2411.lib
opencv_superres2411.lib
opencv_ts2411.lib
opencv_video2411.lib
opencv_videostab2411.lib

你可能感兴趣的:(C\C++)