3rd party and static libs : error LNK2019 with MSVC 2010 32 bits
Hi,
I'm trying to link a MSVC 2010 project with OpenCV 2.4.2 static libs.
The static libs have been compiled with Visual Studio as well, I unchecked the BUILD_SHARED_LIBS and BUILD_WITH_STATIC_CRT when generating the solution with CMake.
It seems there is a linking problem with one of the 3rd party objects. My code calls some methods from the core, highgui, imgproc and objdetect modules. The include folders are added to the include path, and the libs added in the additional libs as well. I also included the 3rd party libs generated ...
The errors are the following :
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIFileInit@0 référencé dans la fonction "void __cdecl icvInitCapture_VFW(void)" (?icvInitCapture_VFW@@YAXXZ)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIStreamGetFrameOpen@8 référencé dans la fonction "public: virtual bool __thiscall CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UAE_NPBD@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIStreamInfoA@12 référencé dans la fonction "public: virtual bool __thiscall CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UAE_NPBD@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIFileGetStream@16 référencé dans la fonction "public: virtual bool __thiscall CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UAE_NPBD@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIFileOpenA@16 référencé dans la fonction "public: virtual bool __thiscall CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UAE_NPBD@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIStreamGetFrame@8 référencé dans la fonction "public: virtual bool __thiscall CvCaptureAVI_VFW::grabFrame(void)" (?grabFrame@CvCaptureAVI_VFW@@UAE_NXZ)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _ICClose@4 référencé dans la fonction "protected: void __thiscall CvCaptureCAM_VFW::closeHIC(void)" (?closeHIC@CvCaptureCAM_VFW@@IAEXXZ)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _ICSendMessage@16 référencé dans la fonction "protected: void __thiscall CvCaptureCAM_VFW::closeHIC(void)" (?closeHIC@CvCaptureCAM_VFW@@IAEXXZ)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _capCreateCaptureWindowA@32 référencé dans la fonction "public: virtual bool __thiscall CvCaptureCAM_VFW::open(int)" (?open@CvCaptureCAM_VFW@@UAE_NH@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _capGetDriverDescriptionA@20 référencé dans la fonction "public: virtual bool __thiscall CvCaptureCAM_VFW::open(int)" (?open@CvCaptureCAM_VFW@@UAE_NH@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIFileRelease@4 référencé dans la fonction "public: virtual void __thiscall CvVideoWriter_VFW::close(void)" (?close@CvVideoWriter_VFW@@UAEXXZ)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIStreamRelease@4 référencé dans la fonction "public: virtual void __thiscall CvVideoWriter_VFW::close(void)" (?close@CvVideoWriter_VFW@@UAEXXZ)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIStreamSetFormat@16 référencé dans la fonction "protected: bool __thiscall CvVideoWriter_VFW::createStreams(struct CvSize,bool)" (?createStreams@CvVideoWriter_VFW@@IAE_NUCvSize@@_N@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVIMakeCompressedStream@16 référencé dans la fonction "protected: bool __thiscall CvVideoWriter_VFW::createStreams(struct CvSize,bool)" (?createStreams@CvVideoWriter_VFW@@IAE_NUCvSize@@_N@Z)
1>opencv_highgui242.lib(cap_vfw.obj) : error LNK2019: symbole externe non résolu _AVISaveOptions@20 ...
Well, why would you uncheck those two? I'm not sure, but I think the lib files are generated only when BUILD_ WITH STATIC CRT is checked. Were you able to compile before unchecking those two?
I unchecked BUILD_SHARED_LIBS to generate the static libraries ... The other is unchecked because of the possible CRT conflict when compiling with /MD or /MT flag. Does anybody know if this cap_vfw.obj is related to open_ffmpeg ? It seems that FFMPEG won't build as a static library, for licence reason (cf https://code.ros.org/trac/opencv/ticket/687), and one must use the DLL dynamically. How to achieve that ?
It seems that FFMPEG cannot be built as a static lib, due to licence conflits with OpenCV (https://code.ros.org/trac/opencv/ticket/687). Therefore the only possibility is to link the project statically with the other libs, and use the generated DLL for FFMPEG. But there is no dynamic lib generated for FFMPEG, how to link it then with only the DLL ?