How to compile OpenCV 3.0 static libs with Visual Studio.

  1. Download Visual Studio 2015 https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx .
  2. Download sources from https://github.com/Itseez/opencv with git to the directory named like opencvSRC (in my case it will be c:\temp\opencvSRC\ ).
  3. Download CMake https://cmake.org/download/ . I preffer Windows ZIP - https://cmake.org/files/v3.5/cmake-3.5.0-win32-x86.zip .
  4. Create directory named as opencvBUILD (in my case - c:\temp\opencvBUILD\ ).
  5. Open cmake-gui.exe from CMake distrib.
  6. Fill fields:
    Where is the source code: c:\temp\opencvSRC\
    Where to build the binaries: c:\temp\opencvBUILD\
    and press Configure button.
  7. Specify Specify the Generator for the project:
  8. When Configuration process will be finished, use default configuration parameters (don't change selectors on red background) and press Generate button.
  9. Close CMake.
  10. Open generated project OpenCV.sln in the dir c:\temp\opencvBUILD\ .
  11. In the Visual Studio 2015 Solution Explorer select all projects in <strong>3rdparty</strong> container and open Properties:
  12. Open C/C++ -> Code Generation and set Runtime Library as Multi-threaded (/MT):
  13. In the Solution Explorer select all projects in modules container and open Properties. Open C/C++ -> Code Generation and set Runtime Library as Multi-threaded (/MT):
  14. Open General in the Configuration Properties, set Target Extension as .lib , set Configuration Type with Static Lybrary (.lib):
  15. In the Solution Explorer select all projects in object_libraries container and open Properties. Open C/C++ -> Code Generation and set Runtime Library as Multi-threaded (/MT):
  16. After that, you will be able to compile needed projects, for example, opencv_core.