C++ - OpenCV - Setting up with Visual Studio

OpenCV is an interesting library aimed to computer vision.

But before playing with it, it's necessary to set up your IDE.

This IDE will be Visual Studio for this tutorial.

So let's get started.

First of all

Let's start by downloading the OpenCV library from the official GitHub.

For this tutorial we'll use the 4.5.3 version:

For the latest version, it should be there:

Take the following file for our tutorial:

  • opencv-4.5.3-vc14_vc15.exe

Run it and extract all files within in a folder as for example:

  • C:\p\mylib\opencv

Setting up Visual Studio

We'll use the Visual Studio 2019 version for this tutorial.

So the compiler will be version vc15.

If you had Visual Studio 20217 then the compiler version would have been vc14.

Open your Visual Studio and create a C++ console project.

Once done, right click your project directly from Visual Studio then select Properties.

Add the following settings :

  • C/C++ > General > Additional Include directories > C:\p\mylib\opencv\build\include
  • Linker > General > Additional Library directories > C:\p\mylib\opencv\build\x64\vc15\lib
  • Linker > Input > Additional Dependencies > opencv_world453d.lib

This latter file can be found there:

  • C:\p\mylib\opencv\build\x64\vc15\lib

Then you have to specify where you can find the .DLL file, such as:

  • opencv_world453d.dll

Note the "d" letter at the end of the file name.

This "d" means debug.

This is because we are going to program our software in the Debug mode.

For the Release one (not with the "d" letter), take the other file, such as:

  • opencv_world453.dll.

If your program generated (.EXE) doesn't know where is this .DLL, then you'll have an error like this:

The code execution cannot proceed because opencv_world452.dll was not found. Reinstalling the program may fix this problem.

Environment variables

So in order to prevent this kind of error, we'll to set our Environment variables.

Create a new variable then specify the following path:

  • C:\p\mylib\opencv\build\x64\vc15\bin

The both .DLLs can indeed be found there.

Don't forget now to add this variable to your PATH.

Then close your Visual Studio (if it is already opened) because the Environment variables aren't updated automatically in Visual Studio.

Open it again and you are now ready to code your first OpenCV program.


A bit annoying as always for setting up your Visual Studio.

But once done, you won't have to modify it in the future.

So great job. cool



vc14 is Visual Studio 2015
vc15 is Visual Studio 2017


Thank you Chris, you are right smiley

We also add that vc16 is for VS2019.

Nevertheless, it's possible to use a version of Visual Studio with an older vc version.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.