Ask Your Question
0

LNK2019 error only on debug compilation [closed]

asked 2019-09-11 19:27:07 -0500

Glerp gravatar image

Hello.

I'm new to OpenCV. I'm using OpenCV 4 on Visual Studio 2017 on a Windows 7 OS. I'm trying to compile the first tutorial app ' How to build applications with OpenCV inside the "Microsoft Visual Studio" '. It compiles and executes correctly on the release configuration, but it gives an LNK2019 linker error on the debug configuration. I compared the common library directories, C/C++ additional include directories, linker additional library directories and linker input additional dependencies properties for both Debug and Release configurations (x64) and are the same except for the final 'd' on debug libraries at additional dependencies.

The linker error is on imshow function, supposedly to be at opencv_imgcodecs412d.lib, which is correctly referenced at Debug|x64 -> Linker -> Input -> Additional dependencies.

These are the libraries included:

opencv_calib3d412d.lib opencv_core412d.lib opencv_dnn412d.lib opencv_features2d412d.lib opencv_flann412d.lib opencv_gapi412d.lib opencv_highgui412d.lib opencv_imgcodecs412d.lib opencv_imgproc412d.lib opencv_ml412d.lib opencv_objdetect412d.lib opencv_photo412d.lib opencv_stitching412d.lib opencv_video412d.lib opencv_videoio412d.lib

This is the error displayed:

Error LNK2019 símbolo externo "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &,class cv::debug_build_guard::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@debug_build_guard@1@@Z) sin resolver al que se hace referencia en la función main

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2019-09-16 01:23:24.292466

Comments

imshow is in opencv_highgui412d.lib

use cmake

LBerger gravatar imageLBerger ( 2019-09-12 02:22:40 -0500 )edit

Hi. Thanks for your response. opencv_highgui412d.lib is also included in additional dependencies, as listed on my post.

I used cmake to generate the OpenCV solution and then built the debug and release binaries in VS2017. In fact, all the libraries seem to be present, but the linker shows me that error when I try to build an application on debug mode, working perfectly on release mode.

Do you mean I need to re-generate the solution with cmake? (and then re-built the binaries)

Glerp gravatar imageGlerp ( 2019-09-13 18:21:50 -0500 )edit

Did you generate opencv in release an debug or did you get opencv on web? When you generate your project did you choose x64 memory model inside cmake gui? Check debug and release libraries in your project (in vs 2017) . Can you choose english language in vs2017 to write error message in english

LBerger gravatar imageLBerger ( 2019-09-14 00:37:24 -0500 )edit

I generated opencv in both release and debug.

I'm sure I choosed x64 in cmake, but I'm going to re-generate de project to be sure. I will put here the result.

Both release and debug libraries are present, but for some reason it can´t find that function in the libraries.

I don't want to change language in vs2017, but i can translate the error:

Error LNK2019 unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &,class cv::debug_build_guard::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@debug_build_guard@1@@Z) referenced in function main

Glerp gravatar imageGlerp ( 2019-09-15 15:24:25 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2019-09-15 17:01:42 -0500

Glerp gravatar image

updated 2019-09-15 17:02:31 -0500

Now it works.

I started installation again from cmake. I deleted the cache at cmake-gui and then configured and generated the OpenCV project again and now it seems to be working correctly.

Thank you very much.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-09-11 19:27:07 -0500

Seen: 40 times

Last updated: Sep 15