title: 'min (& max) not a member of std' errors when building OpenCV 2.4.6 on Windows 8 for Visual Studio 2012
body: <p>I'm trying to build OpenCV 2.4.6 on Windows 8 in Visual Studio 2012. Having downloaded the source from <a href="https://github.com/Itseez/opencv" rel="noreferrer">https://github.com/Itseez/opencv</a> I generate (leaving the default configuration) using cmake and then load the resulting file <code>ALL_BUILD.vcxproj</code> 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:</p>
  
  <p>error C2039: 'max' : is not a member of 'std'   C:\OpenCV2.4.6\3rdparty\openexr\Imath\ImathMatrixAlgo.cpp   1094    1   IlmImf</p>
  
  <p>One fix for errors like this (e.g. in <a href="https://stackoverflow.com/a/6570154/575530">this answer</a>) is to add <code>#include &lt;algorithm&gt;</code> 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 <a href="http://sourceforge.net/projects/opencvlibrary/" rel="noreferrer">the OpenCV sourceforge site</a>) so I would like to understand how to build it on my machine without changing the source.</p>
  
  <p>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?</p>
  
  <p>========== EDIT ==========</p>
  
  <p>Looking at the directory path this appears to be a problem with one of the 3rd party dependencies, OpenEXR. Looking <a href="https://github.com/Itseez/opencv/tree/master/3rdparty/openexr" rel="noreferrer">on Github</a> 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 <a href="http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html" rel="noreferrer">Installation on Windows</a> state:</p>
  
  <ul>
  <li>In case of the Eigen library it is again a case of download and extract to the D:/OpenCV/dep directory.</li>
  <li>Same as above with OpenEXR.</li>
  </ul>
  
  <p>so I downloaded the <a href="https://github.com/downloads/openexr/openexr/openexr-1.7.1.tar.gz" rel="noreferrer">OpenEXR 1.7.1 source code release</a> and extracted the resulting files putting the directory <code>openexr-1.7.1</code> into <code>C:\OpenCV2.4.6\dep</code>.</p>
  
  <p>Then I ran cmake and tried to build the resulting Visual Studio solution. Sadly I see the same errors.</p>