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 libraries instead of dynamic libraries.
I changed the library directories in project VC++ directory from
C:hirdpartyopencvuildx86vc11lib
to: C:hirdpartyopencvuildx86vc11staticlib
but when I want to build the project, I am getting a lot of linker error such as:
Error 110 error LNK2001: unresolved external symbol _TIFFWriteScanline myprojectopencv_highgui245.lib(grfmt_tiff.obj)
and more importantly a lot of error such as this:
Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in myproject.obj myprojectopencv_core245.lib(system.obj)
What other changes should I do to convert a project which uses dynamic libraries to use static libraries?
Edit 1
After change /md to /mt and adding some new libraries to the list of input libraries:
opencv_calib3d245.lib
opencv_contrib245.lib
opencv_core245.lib
opencv_features2d245.lib
opencv_flann245.lib
libtiff.lib
libpng.lib
libjpeg.lib
libjasper.lib
IlmImf.lib
zlib.lib
opencv_gpu245.lib
opencv_haartraining_engine.lib
opencv_highgui245.lib
opencv_imgproc245.lib
opencv_legacy245.lib
opencv_ml245.lib
opencv_nonfree245.lib
opencv_objdetect245.lib
opencv_photo245.lib
opencv_stitching245.lib
opencv_ts245.lib
opencv_video245.lib
opencv_videostab245.lib
I am getting some new errors:
Error 9 error LNK2001: unresolved external symbol _AVIFileCreateStreamA@12 myprojectopencv_highgui245.lib(cap_vfw.obj)
Error 8 error LNK2001: unresolved external symbol _AVIFileGetStream@16 myprojectopencv_highgui245.lib(cap_vfw.obj)
Error 5 error LNK2001: unresolved external symbol _AVIFileInit@0 myprojectopencv_highgui245.lib(cap_vfw.obj)
Error 7 error LNK2001: unresolved external symbol _AVIFileOpenA@16 myprojectopencv_highgui245.lib(cap_vfw.obj)
Apparently some library is missing, but which one?
Edit 2 need to add more library to list. Full list of library is as follow:
opencv_calib3d245.lib
opencv_contrib245.lib
opencv_core245.lib
opencv_features2d245.lib
opencv_flann245.lib
libtiff.lib
libpng.lib
libjpeg.lib
libjasper.lib
IlmImf.lib
zlib.lib
opencv_gpu245.lib
opencv_haartraining_engine.lib
opencv_highgui245.lib
opencv_imgproc245.lib
opencv_legacy245.lib
opencv_ml245.lib
opencv_nonfree245.lib
opencv_objdetect245.lib
opencv_photo245.lib
opencv_stitching245.lib
opencv_ts245.lib
opencv_video245.lib
opencv_videostab245.lib
Vfw32.Lib
comctl32.lib
This solved the problem.
See Question&Answers more detail:os