Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'min (& max) not a member of std' errors when building OpenCV 2.4.6 on Windows 8 for Visual Studio 2012

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:

error C2039: 'max' : is not a member of 'std' C:\OpenCV2.4.6\3rdparty\openexr\Imath\ImathMatrixAlgo.cpp 1094 1 IlmImf

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 ==========

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:

  • In case of the Eigen library it is again a case of download and extract to the D:/OpenCV/dep directory.
  • Same as above with OpenEXR.

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.6\dep.

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

like image 692
dumbledad Avatar asked Oct 18 '13 00:10

dumbledad


People also ask

What do min means?

Min. is a written abbreviation for minimum, or for , minutes or , minute1.

Is min a word in English?

Min. is a written abbreviation for minimum, or for minutes or minute.

Is min a word in Scrabble?

MIN is not a valid scrabble word.

Is it min or min?

Minutes abbreviated This means that “minutes” becomes “min,” with both singular and plural numbers. Flight time is approximately 28 min. The marathon winner averaged 5 min per mile. As an adjective, “minute” is used in its singular form.


1 Answers

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

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.

like image 53
Shodan Avatar answered Oct 06 '22 08:10

Shodan