【问题标题】:Installing OpenCV in C++ Visual Studio: How can I fix these linker errors that occur although I followed the installation tutorial?在 C++ Visual Studio 中安装 OpenCV:如何修复这些链接器错误,尽管我遵循了安装教程?
【发布时间】:2022-01-23 00:53:22
【问题描述】:

我已尝试将 C++ OpenCV 库下载到 Visual Studio 2019。 尝试编译我的代码时,出现以下错误:

1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(40,9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(40,19): error C2059: syntax error: 'constant'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(42,1): error C2143: syntax error: missing ';' before '{'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(42,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,62): error C2039: 'has_parenthesis_operator': is not a member of 'cv::sfinae'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(39): message : see declaration of 'cv::sfinae'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,1): error C2065: 'has_parenthesis_operator': undeclared identifier
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,1): error C2977: 'std::enable_if': too many template arguments
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(46): message : see declaration of 'std::enable_if'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,117): error C2955: 'std::enable_if': use of class template requires template argument list
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(46): message : see declaration of 'std::enable_if'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,131): error C2988: unrecognizable template declaration/definition
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(68,131): error C2059: syntax error: '>'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,11): error C2988: unrecognizable template declaration/definition
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,11): error C2059: syntax error: 'public'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,1): error C2143: syntax error: missing ';' before '{'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(69,1): error C2447: '{': missing function header (old-style formal list?)
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,26): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(140): message : see reference to class template instantiation 'cv::Ptr<T>' being compiled
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,35): error C2059: syntax error: 'constant'
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(80,26): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>C:\opencv-4.5.4\opencv\build\include\opencv2\core\cvstd_wrapper.hpp(140,1): fatal error C1903: unable to recover from previous error(s); stopping compilation

我怀疑这是一个链接器错误,所以我继续并确保我已经包含了所有依赖项和库,并且我做了如下操作,我包含了 opencv 库和库目录并添加了额外的依赖项:

但我仍然遇到同样的错误。有谁知道我怎样才能摆脱它们? 感谢您的帮助!

图片链接:https://imgur.com/a/M1UV7yL

【问题讨论】:

  • 我没有发现任何错误。如果您发布了图片,请不要这样做。复制/粘贴文本。它对每个人来说都更快、更容易,并且遵循本网站的指南。
  • @sweenish 我正在更新它,你看不到图像吗?
  • 我什至看不到典型的死图像框。这并不罕见。大多数人在一天中的这个时间都在工作。
  • @sweenish 我明白了,添加了错误。我怀疑它们是链接器错误,但我不知道要在 Visual Studio 中进行哪些更改才能使其正常工作。
  • 你还必须展示你是如何编译代码的。如果您必须显示 VS 窗口,这可能是可以接受图像的实例。但是,它会限制您的潜在受众。但如果它只是一个命令或一个 makefile 或 CMakeLists.txt,则应将其添加为文本。在我看来,您没有正确构建,在 CLI 上通常缺少-lib&lt;foo&gt;。我对 openCV 本身没有经验。

标签: c++ opencv dll


【解决方案1】:

更新: 通过创建一个新文件并复制创建错误的文件的内容来修复它。我不知道为什么,但它对我有用,也可能对你有用。

祝你好运:)

【讨论】:

    猜你喜欢
    • 2022-05-26
    • 2017-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-03
    • 2015-01-25
    • 2012-07-16
    • 1970-01-01
    相关资源
    最近更新 更多