title: Installation of OpenCV 2.4.5 on Visual Studio 2008
body: <p>I'm having some difficulties trying to use OpenCV with visual studio 2008 (Professional Edition). I believe I've done everything necessary to run a OpenCV sample, but it crashes due to a run-time error. This is driving me insane, I hope someone can help.</p>
  
  <p>But first things first.</p>
  
  <h2>My Installation Procedure</h2>
  
  <ol>
  <li><p>Downloaded <a href="http://ufpr.dl.sourceforge.net/project/opencvlibrary/opencv-win/2.4.5/OpenCV-2.4.5.exe" rel="nofollow noreferrer">OpenCV 2.4.5</a> from sourcefourge.net.</p></li>
  <li><p>When prompted, I chose "Z:\Games instalados\OpenCV" as my "Extract to" option in the .exe downloaded from the above link.</p></li>
  <li><p>Went to "Control Panel" -> "System" -> "Advanced System Settings", then clicked on the "Environment Variables" in the "Advanced" tab. In the "System Variables" box I highlighted "Path" and clicked on "Edit...". In the new window I added to the end of the text in "Variable Value" my installation directory with a ";" before it, namely ";Z:\Games instalados\OpenCV\opencv\build\x86\vc11\bin" (without the double quotes). Here's a screenshot: <img src="https://s10.postimg.org/wsxj8h9i1/environment_variables.jpg" alt="screenshot">.</p></li>
  <li>Created a new project in Visual Studio 2008: File -> New -> Project..., chose "Other Languages" -> "Visual C++ -> "Win32" as the project type; "Win32 Console Application" as the template. <img src="https://s3.postimg.org/gf9x22omr/newproject.jpg" alt="new project"> Clicked "next" in the new window, then chose "Console Application", "Empty Project" and then "Finish". <img src="https://s10.postimg.org/9jpmv87dl/app_type.jpg" alt="new window"></li>
  <li>In the "Solution Explorer", right-clicked my program and chose "Properties". Then "Configuration Properties" -> "C/C++" -> "General", and on Additional Include Directories I've added: 
  
  <ul>
  <li>Z:\Games instalados\OpenCV\opencv\build\include</li>
  <li>Z:\Games instalados\OpenCV\opencv\build\include\opencv</li>
  <li>Z:\Games instalados\OpenCV\opencv\build\include\opencv2
  "<img src="https://s23.postimg.org/6yad3hvbf/additional_include_directories.jpg" alt="Additional Include"></li>
  </ul></li>
  <li>Now in "Configuration Properties" -> "C/C++" -> "Linker" -> "General", in the "Additional Library Directories" I've added "Z:\Games instalados\OpenCV\opencv\build\x86\vc11\lib". <img src="https://s9.postimg.org/gc7xzh1db/additional_library.jpg" alt="Additional Library"></li>
  <li>Now in "Configuration Properties" -> "C/C++" -> "Linker" -> "Input", in the "Additional Dependencies" I've added:
  
  <ul>
  <li>opencv_calib3d245.lib</li>
  <li>opencv_contrib245.lib</li>
  <li>opencv_core245.lib</li>
  <li>opencv_features2d245.lib</li>
  <li>opencv_flann245.lib</li>
  <li>opencv_gpu245.lib</li>
  <li>opencv_highgui245.lib</li>
  <li>opencv_imgproc245.lib</li>
  <li>opencv_legacy245.lib</li>
  <li>opencv_ml245.lib</li>
  <li>opencv_nonfree245.lib</li>
  <li>opencv_objdetect245.lib</li>
  <li>opencv_photo245.lib</li>
  <li>opencv_stitching245.lib</li>
  <li>opencv_superres245.lib</li>
  <li>opencv_ts245.lib</li>
  <li>opencv_video245.lib</li>
  <li>opencv_videostab245.lib</li>
  <li>opencv_calib3d245d.lib</li>
  <li>opencv_contrib245d.lib</li>
  <li>opencv_core245d.lib</li>
  <li>opencv_features2d245d.lib</li>
  <li>opencv_flann245d.lib</li>
  <li>opencv_gpu245d.lib</li>
  <li>opencv_highgui245d.lib</li>
  <li>opencv_imgproc245d.lib</li>
  <li>opencv_legacy245d.lib</li>
  <li>opencv_ml245d.lib</li>
  <li>opencv_nonfree245d.lib</li>
  <li>opencv_objdetect245d.lib</li>
  <li>opencv_photo245d.lib</li>
  <li>opencv_stitching245d.lib</li>
  <li>opencv_superres245d.lib</li>
  <li>opencv_ts245d.lib</li>
  <li>opencv_video245d.lib</li>
  <li>opencv_videostab245d.lib
  (Please note that I didn't added "opencv_ffmpeg245.lib", despite what the screenshot shows).
  <img src="https://s23.postimg.org/3ygy31juz/additional_dependencies.jpg" alt="Additional Dependencies"></li>
  </ul></li>
  <li>Right-clicked "Source Files" -> "Add" -> "Existing Item" and added the "Z:\Games instalados\OpenCV\opencv\samples\cpp\cout_mat.cpp" file.
  <img src="https://s3.postimg.org/5pwot6trn/added_cout.jpg" alt="Added cout_mat"></li>
  </ol>
  
  <h2>The Problem</h2>
  
  <ol>
  <li>Built the project, no problems here, "Build succeeded".</li>
  <li>"Debug" -> "Start Debugging". The following appears:
  <a href="http://s8.postimg.org/wdkubk5o3/the_error.jpg" rel="nofollow noreferrer">The error http://s8.postimg.org/wdkubk5o3/the_error.jpg</a>
  Full size image for the error: <a href="http://s8.postimg.org/wdkubk5o3/the_error.jpg" rel="nofollow noreferrer">http://s8.postimg.org/wdkubk5o3/the_error.jpg</a></li>
  </ol>
  
  <p>I've also tried with the hough lines sample, but it didn't worked as well (even with the image in the same folder as the .exe imread() wouldn't find the image).</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>If I've not made some of the installation steps clear enough, please post a comment.</p>
  
  <h2>Reason this question is suited for stackoverflow.com</h2>
  
  <p>I've detailed a full installation procedure (from scratch) for the latest release of OpenCV to be used with Visual Studio 2008. If anyone solves this question we will have a complete, working tutorial for anyone having the same necessity (use latest OpenCV with visual studio 2008), and possibly (because of the depth in the installation procedure) a general guide for installing the latest OpenCV with most Visual Studio versions (not just the 2008, since the tutorial wouldn't change much, and the reader could easily adapt it). </p>