如何使用openCV依赖项使用C++ 20来编译我的项目?

发布于 2025-01-27 05:12:30 字数 1540 浏览 2 评论 0原文

我正在尝试使用G ++上的C ++ 20标志来构建我的项目。我的项目取决于OpenCV 4.0的OpenCV.HPP中的某些标题,现在我会从这些标头文件中获取编译器错误。我无法从OpenCV的文档中分辨出他们是否支持使用C ++ 20标志编译。我在哪里可以找到该信息?

还有一种方法可以解决这些错误吗?如何使用较旧的C ++标准编译他们的代码?但是我的代码使用C ++ 20?

这是我看到的编译器错误的片段:

In file included from /usr/include/opencv4/opencv2/core/mat.hpp:3724,
                 from /usr/include/opencv4/opencv2/core.hpp:59,
                 from /usr/include/opencv4/opencv2/opencv.hpp:52,
                 from /my_project/include/amp_ffmpeg/decoder.hpp:3,
                 from /my_project/src/decoder.cpp:1:
/usr/include/opencv4/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputArray::_InputArray(const cv::Mat&)’:
/usr/include/opencv4/opencv2/core/mat.inl.hpp:88:57: error: arithmetic between different enumeration types ‘cv::_InputArray::KindFlag’ and ‘cv::AccessFlag’ is deprecated [-Werror=deprecated-enum-enum-conversion]
   88 | inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); }
      |                                                      ~~~^~~~~~~~~~~~
/usr/include/opencv4/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputArray::_InputArray(const std::vector<cv::Mat>&)’:
/usr/include/opencv4/opencv2/core/mat.inl.hpp:89:83: error: arithmetic between different enumeration types ‘cv::_InputArray::KindFlag’ and ‘cv::AccessFlag’ is deprecated [-Werror=deprecated-enum-enum-conversion]
   89 | inline _InputArray::_InputArray(const std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); }

I am trying to build my project with the c++20 flag on g++-11. My project depends on some headers in opencv.hpp from OpenCV 4.0, and now I'm getting compiler errors from these header files. I can't tell from OpenCV's docs if they support compiling with the c++20 flag. Where can I find that info?

Also is there a way to get around these errors? How could I compile their code with an older c++ standard?, but my code with c++20?

Here's a snippet of the compiler error that I'm seeing:

In file included from /usr/include/opencv4/opencv2/core/mat.hpp:3724,
                 from /usr/include/opencv4/opencv2/core.hpp:59,
                 from /usr/include/opencv4/opencv2/opencv.hpp:52,
                 from /my_project/include/amp_ffmpeg/decoder.hpp:3,
                 from /my_project/src/decoder.cpp:1:
/usr/include/opencv4/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputArray::_InputArray(const cv::Mat&)’:
/usr/include/opencv4/opencv2/core/mat.inl.hpp:88:57: error: arithmetic between different enumeration types ‘cv::_InputArray::KindFlag’ and ‘cv::AccessFlag’ is deprecated [-Werror=deprecated-enum-enum-conversion]
   88 | inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); }
      |                                                      ~~~^~~~~~~~~~~~
/usr/include/opencv4/opencv2/core/mat.inl.hpp: In constructor ‘cv::_InputArray::_InputArray(const std::vector<cv::Mat>&)’:
/usr/include/opencv4/opencv2/core/mat.inl.hpp:89:83: error: arithmetic between different enumeration types ‘cv::_InputArray::KindFlag’ and ‘cv::AccessFlag’ is deprecated [-Werror=deprecated-enum-enum-conversion]
   89 | inline _InputArray::_InputArray(const std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文