在 Windows 8 上为 Visual Studio 2012 构建 OpenCV 2.4.6 时出现“min (& max) not a member of std"错误 [英] 'min (& max) not a member of std' errors when building OpenCV 2.4.6 on Windows 8 for Visual Studio 2012

查看:20
本文介绍了在 Windows 8 上为 Visual Studio 2012 构建 OpenCV 2.4.6 时出现“min (& max) not a member of std"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Visual Studio 2012 中的 Windows 8 上构建 OpenCV 2.4.6.从 https 下载了源代码://github.com/Itseez/opencv 我使用 cmake 生成(保留默认配置),然后将生成的文件 ALL_BUILD.vcxproj 加载到 Visual Studio 2012 中.然后我尝试构建它.确实有几个模块确实构建了(例如 core、flann、imgproc 等),但我正在尝试构建 highgui,以便我可以使用 PDB 文件来调试我的代码(无法打开视频文件).构建错误开始于这个错误和许多类似的错误:

I'm trying to build OpenCV 2.4.6 on Windows 8 in Visual Studio 2012. Having downloaded the source from https://github.com/Itseez/opencv I generate (leaving the default configuration) using cmake and then load the resulting file ALL_BUILD.vcxproj into Visual Studio 2012. I then try to build it. Several of the modules do indeed build (e.g. core, flann, imgproc, ...) but I am trying to build highgui so that I can use the PDB file for debugging my code (which fails to open a video file). The build errors start with this and many similar errors:

错误 C2039: 'max' : 不是 'std' C:OpenCV2.4.63rdpartyopenexrImathImathMatrixAlgo.cpp 1094 1 IlmImf 的成员

error C2039: 'max' : is not a member of 'std' C:OpenCV2.4.63rdpartyopenexrImathImathMatrixAlgo.cpp 1094 1 IlmImf

解决此类错误的一种方法(例如在 this answer 中)是添加 #include ; 到失败的文件.我在几个文件上尝试过,它似乎有效,但我对在本地更改流行库的源感到紧张.它必须在 Windows 上构建(您可以从 OpenCV sourceforge 站点) 所以我想了解如何在不更改源代码的情况下在我的机器上构建它.

One fix for errors like this (e.g. in this answer) is to add #include <algorithm> to the failing files. I tried that on a few files and it seems to work but I'm nervous about locally changing the source for a popular library. It must build on Windows (you can download the binaries, though not the PDB files, from the OpenCV sourceforge site) so I would like to understand how to build it on my machine without changing the source.

我在配置步骤中遗漏了什么吗?我的机器上是否缺少某些路径设置等?为什么我会收到这些错误,我应该如何修复它们?

Am I missing something out in the configuration step? Is there some path setting etc. missing on my machine? Why am I getting these errors and how should I fix them?

========== 编辑 ==========

========== EDIT ==========

查看目录路径,这似乎是第 3 方依赖项之一 OpenEXR 的问题.在 在 Github 上看,它似乎是 OpenEXR 的 1.7.1 版在 OpenCV 2.4.6 中使用.OpenCV 快速入门中的说明在 Windows 上安装 状态:

Looking at the directory path this appears to be a problem with one of the 3rd party dependencies, OpenEXR. Looking on Github it appears to be version 1.7.1 of OpenEXR that is used in OpenCV 2.4.6. The instructions in the OpenCV's Quick Start Installation on Windows state:

  • 在 Eigen 库的情况下,再次下载并解压到 D:/OpenCV/dep 目录.
  • 与上面的 OpenEXR 相同.

所以我下载了OpenEXR 1.7.1 源代码发布 并提取结果文件,将目录 openexr-1.7.1 放入 C:OpenCV2.4.6dep.

so I downloaded the OpenEXR 1.7.1 source code release and extracted the resulting files putting the directory openexr-1.7.1 into C:OpenCV2.4.6dep.

然后我运行 cmake 并尝试构建生成的 Visual Studio 解决方案.很遗憾,我看到了同样的错误.

Then I ran cmake and tried to build the resulting Visual Studio solution. Sadly I see the same errors.

推荐答案

我在编译 OpenEXR 时遇到了同样的问题.然后我找到了 openexr std::min 的解决方案.

I was stumbling on the same issue while compiling OpenEXR. Then I found the solution googling for openexr std::min.

在 OpenCV 上打开了一个问题,其中说,在使用 VS2013 预览版时,您必须添加行 #include 在您使用 std::minstd::max 的文件中.

There is an issue opened on OpenCV where it says that, when using VS2013 Preview, you must add the line #include <algorithm> in the file where you're using std::min and std::max.

我把那行放到调用这些方法的文件中,瞧!编译成功.

I put that line into the files where these methods are called and voilà! Compilation succeeded.

这篇关于在 Windows 8 上为 Visual Studio 2012 构建 OpenCV 2.4.6 时出现“min (&amp; max) not a member of std"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆