【发布时间】:2021-04-03 09:58:34
【问题描述】:
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
当我使用 OpenCV 调试构建 opencv_world451d.lib,vscode
不会编译我的项目。如果我切换到 OpenCV release build opencv_world451.lib,那么一切都很好。
这很奇怪,因为我在 Visual Studio 2019 中使用了完全相同的设置,并且无论是调试还是发布版本都一切正常。 CMake 也构建它。
这是我的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"
}
]
}
使用debug build时有什么设置需要正确设置吗?
【问题讨论】:
-
'd' 用于调试。您可能需要在其中添加更多参数才能编译。
-
需要设置runtime来匹配opencv库中使用的runtime
标签: c++ opencv visual-studio-code