Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
305 views
Welcome To Ask or Share your Answers For Others

1 Answer

I am able to get the static libraries working in VS 2013 by changing the project's Runtime Library to /MTd

enter image description here

and then including these Linker >> Input >> Additional Dependencies:

opencv_core248d.lib
opencv_imgproc248d.lib
opencv_highgui248d.lib
opencv_ml248d.lib
opencv_video248d.lib
opencv_features2d248d.lib
opencv_calib3d248d.lib
opencv_objdetect248d.lib
opencv_contrib248d.lib
opencv_legacy248d.lib
opencv_flann248d.lib
libpngd.lib
libtiffd.lib
zlibd.lib
IlmImfd.lib
libjasperd.lib
libjpegd.lib
comctl32.lib
gdi32.lib
vfw32.lib

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...