Debugging OpenCV DLL used by Executable
Hey there,
this question is partly related to OpenCV and partly debugging an executable in general, though the latter case is not really part of this forum. This is a long post, but I have the feeling it is better to elaborate on this, as the devil is in the details, and most likely a single lib/ dll is missing etc.
I am working with VS 2013 and have an executable, let's name it main
, which uses OpenCV functionality. I want to debug into one of the functions, more precisely computeDisparitySGBM
in stereoSGBM.cpp. For this reason I build main
in debug configuration and specify it in my OpenCV VS project (see https://docs.microsoft.com/en-us/visu...).
The trouble starts earlier, as I can not build the debug configuration of main
(I can build release though) and receive a bunch of linker errors:
error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class cv::String const &,class cv::debug_build_guard::_InputArray const &)" (?imshow@cv@@YAXAEBVString@1@AEBV_InputArray@debug_build_guard@1@@Z) referenced in function main
error LNK2019: unresolved external symbol "class cv::debug_build_guard::_InputOutputArray const & __cdecl cv::noArray(void)" (?noArray@cv@@YAAEBV_InputOutputArray@debug_build_guard@1@XZ) referenced in function "struct std::pair<class cv::mat,class="" cv::mat=""> __cdecl misc::composeStereoRT(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,class cv::Mat const &)" (?composeStereoRT@misc@@YA?AU?$pair@VMat@cv@@V12@@std@@AEBVMat@cv@@000@Z)
error LNK2019: unresolved external symbol "void __cdecl cv::Rodrigues(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::debug_build_guard::_OutputArray const &)" (?Rodrigues@cv@@YAXAEBV_InputArray@debug_build_guard@1@AEBV_OutputArray@31@1@Z) referenced in function "struct std::pair<class cv::mat,class="" cv::mat=""> __cdecl misc::composeStereoRT(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,class cv::Mat const &)" (?composeStereoRT@misc@@YA?AU?$pair@VMat@cv@@V12@@std@@AEBVMat@cv@@000@Z)
Obviously, the linker does not find the objects, though it does not complain about other functions as imread
. The project containing main
was generated using CMake and the dependencies for release and debug config. are identically:
C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_stitching341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_superres341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_videostab341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_aruco341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_bgsegm341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_bioinspired341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_ccalib341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_dnn_objdetect341.lib C:\Users\local_user\Documents\OpenCV\opencv-3.4.1\build\install\x64\vc12\lib\opencv_dpm341 ...
you have to build DEBUG opencv libs / dll's and link against those for your DEBUG project. (e.g.
opencv_stitching341**d**.lib
(those cv::debug_build_guards are there to show you the problem)
and yep, VS only shows the 1st (few) errors here, there are for sure more of the same problem
@Ziri, the prebuilt opencv_world(d) libs are only for VS 2015/2017. for VS2013, ppl have to build their own.
Thanks . I didn't know that.