7

I'm trying to use openCV243 static libs in 64bit vs10 console application. My OS is win7 64 bit.

I've included following libs:

#pragma comment(lib,"../final_test/libs/staticlib/opencv_core243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_highgui243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_imgproc243.lib")       
#pragma comment(lib,"../final_test/libs/staticlib/opencv_video243d.lib")        
#pragma comment(lib,"../final_test/libs/staticlib/opencv_flann243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_features2d243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_objdetect243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_core243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_calib3d243.lib")       
#pragma comment(lib,"../final_test/libs/staticlib/opencv_legacy243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_features2d243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_ml243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/libjpeg.lib")
#pragma comment(lib,"../final_test/libs/staticlib/libpng.lib")
#pragma comment(lib,"../final_test/libs/staticlib/libtiff.lib")
#pragma comment(lib,"../final_test/libs/staticlib/libjasper.lib")
#pragma comment(lib,"../final_test/libs/staticlib/zlib.lib")
#pragma comment(lib,"../final_test/libs/staticlib/IlmImf.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_videostab243") 
#pragma comment(lib,"../final_test/libs/staticlib/opencv_contrib243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_nonfree243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_photo243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_stitching243.lib")
#pragma comment(lib,"../final_test/libs/staticlib/IlmImf.lib")
#pragma comment(lib,"../final_test/libs/staticlib/opencv_ts243.lib")

The runtime library is: Multi-threaded (/MT)

I get following linking errors.

1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol AVIFileInit referenced in function "void __cdecl icvInitCapture_VFW(void)" (?icvInitCapture_VFW@@YAXXZ)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol AVIStreamGetFrameOpen referenced in function "public: virtual bool __cdecl CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UEAA_NPEBD@Z)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol AVIStreamInfoA referenced in function "public: virtual bool __cdecl CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UEAA_NPEBD@Z)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol AVIFileGetStream referenced in function "public: virtual bool __cdecl CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UEAA_NPEBD@Z)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol AVIFileOpenA referenced in function "public: virtual bool __cdecl CvCaptureAVI_VFW::open(char const *)" (?open@CvCaptureAVI_VFW@@UEAA_NPEBD@Z)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol AVIStreamGetFrame referenced in function "public: virtual bool __cdecl CvCaptureAVI_VFW::grabFrame(void)" (?grabFrame@CvCaptureAVI_VFW@@UEAA_NXZ)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol ICClose referenced in function "protected: void __cdecl CvCaptureCAM_VFW::closeHIC(void)" (?closeHIC@CvCaptureCAM_VFW@@IEAAXXZ)
1>opencv_highgui243.lib(cap_vfw.obj) : error LNK2019: unresolved external symbol ICSendMessage referenced in function "protected: void __cdecl CvCaptureCAM_VFW::closeHIC(void)" (?closeHIC@CvCaptureCAM_VFW@@IEAAXXZ)

...

can anyone help me to rid of this problem? Thank you.

Niko
  • 26,516
  • 9
  • 93
  • 110
user1043413
  • 123
  • 2
  • 6
  • Does it compile when you do not include the "highgui" lib? – Niko Nov 20 '12 at 12:42
  • This might also help: http://stackoverflow.com/questions/849238/how-can-i-resolve-error-lnk2019-unresolved-external-symbol – Niko Nov 20 '12 at 12:43
  • Thanks for your comments. Unfortunately, without highgui the project does not compile. – user1043413 Nov 20 '12 at 19:54
  • Okay, did you also specify those lib files as additional dependencies in the project configuration? That might be necessary. – Niko Nov 20 '12 at 20:33

2 Answers2

14

You need to link with MS vfw32.lib library.

Andrey Kamaev
  • 29,582
  • 6
  • 94
  • 88
  • 2
    also comctl32.lib is needed – Nima May 08 '13 at 12:00
  • @ChaiNadig either add pragmas as in the answer by furqan, or in VC++ 2010 Express: Project Properties (Alt-F7) -> Configuration Properties -> Linker -> Input; click drop-down menu on the value of Additional Dependencies, <Edit...>, paste a list of library files above. You'll have vfw32.lib and comctl32.lib on seperate lines, and libs from %OPENCV_DIR%\build\x86\vc10\staticlib too. – sastanin Nov 03 '14 at 17:24
5

just do this in ur header file. It should work perfectly.

#include "opencv2/opencv.hpp"
#pragma comment(lib, "vfw32.lib")
#pragma comment( lib, "comctl32.lib" )
maxpayne
  • 1,111
  • 2
  • 21
  • 41
  • So there's no 64 bit version I should rather link? Or are these files automatically 64bit in my system32 folder? I'm running a 64bit windows 7. The problem I have is that since I compiled in 64bit, the `cv:VideoCapture::readMat(CV_OUT Mat& image)` returns an empty `cv::Mat` – tzippy Aug 02 '16 at 10:14
  • You should define your dependencies in the cmake file or similar. Linking pragmas are a bad concept to begin with. Why should I define link time dependencies during compilation time? They are also compiler specific and not portable. And those libs of course have 32 in their name because they are part of the win32 name, not because they necessarily are 32bit libraries. Ps.: I was having the issues with the same missing symbols, in my case I added the two win32 libraries two my the list of libraries to link in my conan package for opencv. – MichaelE1000 Sep 04 '18 at 13:17