Reputation: 41
opencv_world451d.lib
helloworld.obj
helloworld.obj : 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::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@Z) referenced in function main
C:\Users\kaito\OneDrive\Documents\Cpp\OpenCVHelloWorld\helloworld.exe : fatal error LNK1120: 1 unresolved externals
When I use OpenCV debug build opencv_world451d.lib
, vscode
won't compile my project. If I switch to OpenCV release build opencv_world451.lib
, then everything is fine.
This is very odd since I used exact the same setting with Visual Studio 2019 and everything was OK with either debug or release build. CMake also build it.
This is my tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Wall",
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}",
"/I",
"C:/Program Files/opencv/build/include",
"/link",
"/LIBPATH:C:/Program Files/opencv/build/x64/vc15/lib",
"opencv_world451d.lib"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always"
},
"detail": "compiler: cl.exe"
}
]
}
Is there any setting need to be set properly when use debug build?
Upvotes: 3
Views: 538
Reputation: 41
I solve the problem by use compiler flag /MDd instead of /MD. Looks like debug build needs the proper debug runtime.
Upvotes: 1