Setting up OpenCV 3.1 in Visual Studio 2015

Ahmad picture Ahmad · Feb 21, 2016 · Viewed 15.9k times · Source

I've downloaded opencv 3.1 and I want to start a project in Visual Studio 2015. I don't know how to link this library to my project. Also I want to know if I can continue with this opencv cause it just have a x64 and my project doesn't target on 64bits systems.

Answer

globalex picture globalex · Feb 25, 2016
  1. Download opencv 3.1 for windows

  2. Extract to folder like c:/opencv

  3. Set environment variables by setx -m. This depends on your path.

Type this into command line started by cmd.

setx -m OPENCV_DIR C:\opencv\build\x64\vc14
  1. In the path editor, under control_panels/system/advanced/environmental_variables just set

    %OPENCV_DIR%\bin

These are important steps. If you include Opencv project without this Project in visual studio failes because the project can not find DLL library.

  1. Under Project settings in Visual Studio

    • C/C++/General set Additional Include Directories and Additional #using Directories. For example C:\opencv\build\include

    • Under Linker/general set Additional library directories you can use your system path set in installation process or simply include this path for 64 bit version. For example C:\opencv\build\x64\vc14\lib or C:\opencv\build\yourTarget\vc14\lib

    • Under Linker/Input set Additional Dependencies as opencv_world310.lib, opencv_world310d.lib

My tutorial to Visual Sturio 2015 and Opencv 3.1

Use Nuget console to install Opencv in VS