Ask Your Question
0

3rd party and static libs : error LNK2019 with MSVC 2010 32 bits

asked 2012-07-16 05:02:09 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

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 ...
(more)
edit retag flag offensive close merge delete

Comments

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?

XCoder gravatar imageXCoder ( 2012-07-16 05:35:53 -0600 )edit

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 ?

Ben B. gravatar imageBen B. ( 2012-07-16 06:37:02 -0600 )edit

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 ?

Ben B. gravatar imageBen B. ( 2012-07-16 07:43:27 -0600 )edit

2 answers

Sort by » oldest newest most voted
1

answered 2012-07-22 09:00:02 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

You need to statically link with vfw32.lib.

edit flag offensive delete link more
0

answered 2012-07-23 16:39:23 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

It is working when using /MD flag, thanks a lot !

I got other problems when trying to use the /MT flag. First, I recompiled OpenCV with the BUILD_WITH_STATIC_CRT flag. Then when building my project with MSVC, I used the /NOLIBRARY flag to avoid linking with msvcrt.lib and msvcprt.lib, and I added libcmt.lib and libcpmt.lib to the entries. However, I still get some linking problems, coming from the other 3rd party libraries (libjasper, libpng, libjpeg, libtiff and zlib) :

1>libjasper.lib(jas_stream.obj) : error LNK2019: symbole externe non résolu __imp__lseek référencé dans la fonction _file_seek
1>OLDNAMES.lib(lseek.obi) : error LNK2001: symbole externe non résolu __imp__lseek
1>libjasper.lib(jas_stream.obj) : error LNK2019: symbole externe non résolu __imp__unlink référencé dans la fonction _file_close
1>OLDNAMES.lib(unlink.obi) : error LNK2001: symbole externe non résolu __imp__unlink
1>libjasper.lib(jas_stream.obj) : error LNK2019: symbole externe non résolu __imp__tmpnam référencé dans la fonction _jas_stream_tmpfile
1>libjasper.lib(jas_stream.obj) : error LNK2019: symbole externe non résolu __imp__setmode référencé dans la fonction _jas_stream_fdopen
1>OLDNAMES.lib(setmode.obi) : error LNK2001: symbole externe non résolu __imp__setmode
1>libjasper.lib(jas_cm.obj) : error LNK2019: symbole externe non résolu __imp__ceil référencé dans la fonction _jas_cmshapmatlut_lookup
1>libjasper.lib(jpc_enc.obj) : error LNK2019: symbole externe non résolu __imp__atof référencé dans la fonction _ratestrtosize
1>libjasper.lib(jpc_util.obj) : error LNK2001: symbole externe non résolu __imp__atof
1>libpng.lib(pngget.obj) : error LNK2001: symbole externe non résolu __imp__atof
1>libjasper.lib(jas_icc.obj) : error LNK2019: symbole externe non résolu __imp__qsort référencé dans la fonction _jas_iccprof_sorttagtab
1>libtiff.lib(tif_dirinfo.obj) : error LNK2001: symbole externe non résolu __imp__qsort
1>libjasper.lib(jpc_util.obj) : error LNK2019: symbole externe non résolu __imp__strtok référencé dans la fonction _jpc_atoaf
1>libjpeg.lib(jmemansi.obj) : error LNK2019: symbole externe non résolu __imp__tmpfile référencé dans la fonction _jpeg_open_backing_store
1>libpng.lib(png.obj) : error LNK2019: symbole externe non résolu __imp__modf référencé dans la fonction _png_ascii_from_fp
1>libpng.lib(png.obj) : error LNK2019: symbole externe non résolu __imp__frexp référencé dans la fonction _png_ascii_from_fp
1>libpng.lib(pngwrite.obj) : error LNK2019: symbole externe non résolu __imp___gmtime64 référencé dans la fonction _gmtime
1>libtiff.lib(tif_win32.obj) : error LNK2019: symbole externe non résolu __imp__vsnprintf référencé dans la fonction _Win32WarningHandler
1>zlib.lib(gzwrite.obj) : error LNK2001: symbole externe non résolu __imp__vsnprintf
1>libtiff.lib(tif_dirinfo.obj) : error LNK2019: symbole externe non résolu __imp__bsearch référencé dans la fonction _TIFFFindField

Any idea which library is missing ?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-07-16 05:02:09 -0600

Seen: 1,977 times

Last updated: Jul 23 '12