using static libraries instead of dynamic libraries in opencv

后端 未结 5 1060
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 08:31

I have a project in visual studio 2012 which uses opencv dynamic libraries. It compiled, linked and worked well.

I want to change the project so it uses static libra

5条回答
  •  独厮守ぢ
    2020-12-01 08:33

    I have build an application which depends on OpenCV 2.4.9 with static linking.

    1) I have just added linker additional dependencies:

    opencv_core249d.lib opencv_imgproc249d.lib opencv_highgui249d.lib opencv_ml249d.lib opencv_video249d.lib opencv_features2d249d.lib opencv_calib3d249d.lib opencv_objdetect249d.lib opencv_contrib249d.lib opencv_legacy249d.lib opencv_flann249d.lib libpngd.lib libtiffd.lib zlibd.lib IlmImfd.lib libjasperd.lib libjpegd.lib comctl32.lib gdi32.lib vfw32.lib

    2) Linker => General => Additional Library Directories => changed $(OPENCV_DIR)\x86\vc12\lib to $(OPENCV_DIR)\x86\vc12\staticlib where OPENCV_DIR is environment variable set to: C:\OpenCV 2.4.9\opencv\build

    3) and changed C/C++ => Code Generation => Multi-threaded debug DLL (MD) to Multi-threaded debug (MTd)

    and enjoyed the successful build.

    the same thing works for release mode (of course link against non-debug libs)

提交回复
热议问题