Search code examples
opencvlnk2019

error LNK2019: unresolved external symbol _ Open CV program


I am learning open CV and for the same i was trying few programs. I am referring to this link. http://docs.opencv.org/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.html

I am using visual studio 10 to run the same, and i think somewhere i have messed up with some configuration. I am facing the same problem in couple of more programs (picked from same source) ,

The error which i get is as follows:-

1>main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function __catch$_main$0

1>main.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::subspaceReconstruct(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &)" (?subspaceReconstruct@cv@@YA?AVMat@1@ABV_InputArray@1@00@Z) referenced in function __catch$_main$0

..... (more such unresolved external symbol error)

1>main.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall cv::_InputArray::empty(void)const " (?empty@_InputArray@cv@@UBE_NXZ)

1>c:\users\isenses\documents\visual studio 2010\Projects\gender_classification\Debug\gender_classification.exe : fatal error LNK1120: 37 unresolved externals

1>

1>Build FAILED.

1>Time Elapsed 00:00:00.36

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

My Project Properties are as follows:-

Properties->Configuration Properties ->Debugging->command arguments->C:\Users\isenses\Documents\Visual Studio 2010\Projects\gender_classification\csv.txt

Properties->Configuration Properties ->VC++ directories->Include directories->(added C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib &
C:\openCV_2.4\opencv\build\x86\vc10\lib)

C/C++->general->additional include directories (added include path of openCV ie:- C:\openCV_2.4\opencv\build

Linker->General--- Enable incremental linking=no

Additional Library directories=C:\Program Files %28x86%29\Microsoft Visual Studio 10.0\VC\lib

C:\openCV_2.4\opencv\build\x86\vc10

linker->System---SubSystem= /SUBSYSTEM:CONSOLE

Linker->Input--- additional dependencies= wsock32.lib opencv_contrib2411d.lib

opencv_calib3d2411d.lib

opencv_ml2411d.lib

opencv_objdetect2411d.lib

Thank you.


Solution

  • Thanks to @miki i was able to build the file successfully. The solution to my problem was:-

    1. adding proper additional Dependencies in properties->linker->input.
    2. Adding libraries path in windows environment variables.
    3. I had not used proper additional dependencies as pointed by @miki and as quoted by him "well you also have to link opencv_coreXXX,opencv_highguiXXX, opencv_imgprocXXX etc... (with trailing "d" if in debug) in your Linker->Input--- additional dependencies"

    Thanks again