OpenCV installation on Windows, missing vc15 folder

Hi everyone,
I’m trying to install OpenCV on my windows 10 machine for academic purpose. I have to follow an installation guide provided by my professor, that requires VisualStudio 2017 and Cmake. I have done literally any point of that guide, that I report -brielfy- here:

  1. Install VisualStudio 2017 and Cmake
  2. Download (from github) opencv-3.3.1 and opencv_contrib-3.3.1 and unzip them into a folder ‘source’ (created before together with another folder ‘build’ inside another folder ‘C:\workspace’)
  3. Use Cmake (Source code: …opencv3\source\opencv, where to build: opencv3\build). Generator: VisualStudio 15 2017 Win64.
  4. When Cmake finishes, look for “OPENCV_EXTRA_MODULES_PATH” and set it to your opencv_contrib/modules path.
    Press Configure and then Generate
  5. Open the OpenCV.sln file with VisualStudio, change to Release the build type, then find the INSTALL project inside CMakeTargets folder and build it.

Now, I need to add to the environment variables a new variable OPENCV_DIR with value …\opencv3\build\install\x64\vc15

Now…the problem is that, inside the install folder, there’s NO x64 DIRECTORY, and I cannot find ANY vc15 DIRECTORY in the entire build folder… I really don’t know how to proceed, since I’ve been looking for a solution for at least 3 hours… Is there anyone that would kindly help me?

Thanks in advance (and sorry if I did s.thing wrong in creating the topic)

What is inside the install directory? Did the build complete without any errors and are you sure you built the INSTALL target?

Directory di C:\workspace\opencv3\build\install

08/03/2021 09:55 <DIR> .
08/03/2021 09:55 <DIR> …
08/03/2021 09:55 <DIR> bin
08/03/2021 09:55 <DIR> etc
08/03/2021 09:55 <DIR> include
08/03/2021 09:55 <DIR> lib
07/03/2021 22:30 2.234 LICENSE
08/03/2021 09:38 433 OpenCVConfig-version.cmake
08/03/2021 09:38 5.605 OpenCVConfig.cmake
3 File 8.272 byte
6 Directory 177.669.537.792 byte disponibili

This is the content of the directory, and…yes, the build completed without any error or warning, and I’m 100% sure I built the INSTALL target under CMakeTargets folder

It looks like the locations for OpenCV 3 are different to 4. Because I am not sure how your OPENCV_DIR variable will be used, I cannot tell you conclusively which directory to set it to. In OpenCV 4 the

directory contains the lib and bin folder. If the OPENCV_DIR is just used for that then you can set it to


However I suspect that OPENCV_DIR could also used to locate the include directory so you may find some of your projects have something similar to


in the project properties, C/C+±>General->Additional Include Directories. In that case you would need to remove the proceeding …\ and just leave

Maybe this (the following of the guide I’m following) may help:

"[after creating OPENCV_DIR] access the Path variable and add the lines:


and confirm."

Does this change anything? I would like to be sure before doing anything

Yes in which case you should be able to use


Not sure why you are adding %OPENCV_DIR%\lib as well as %OPENCV_DIR%\bin maybe cmake etc. picks up the lib paths in your project. Either way the above should work.

Can you post cmakecache.txt?

Here it is @laurent.berger

However, I set …\opencv3\build\install\ as value for OPENCV_DIR, and still nothing works. I’m compiling a sample project provided by my professor, saved as .cpp, that has only the directive:

#include <opencv2\highgui.hpp>

by using cmd:

g++ -o [file] lopencv_highgui -lopencv_core

and the result is always “no such file or directory bla bla bla”… but inside \build\install\include\opencv2 I can find the library highgui.hpp, indeed.
I tried also to modify the OPENCV_DIR variable according to the path were the .hpp file is, but nothing changes

It looks like the OPENCV_DIR variable is being used to detect the headers as well as I suspected in my previous post. Therefore you will need to find where it is referenced, probably something like


and change it to


Just out of interest are you building your project on linux or using g++ on windows?

If you want you can just change

#include <opencv2\highgui.hpp>

to the actual path where highgui.hpp is to check that this is your only issue.

This is the path where all the headers are located. I tried to modify OPENCV_DIR with this, and I changed
to just
but still nothing.

So I tried also to define OPENCV_DIR as:
and then add to path variable
but this was useless.

And also changing the directive with:
#include <highgui.hpp>

I wrote #include <C:\workspace\opencv3\build\install\include\opencv2\highgui.hpp> and this seems to correctly include highgui.hpp, but then the compiler tells me:
C:\workspace\opencv3\build\install\include\opencv2\highgui.hpp:46:28: fatal error: opencv2/core.hpp: No such file or directory #include "opencv2/core.hpp"

This means that highgui was found, but now it doesn’t find core.hpp (that is included INSIDE highgui, as I see)

I’m on windows

Is the project you are building fixed or do you use cmake to generate it?

If its fixed, somewhere in your configuration the path to
will be specified, probably as
If you are unable to find it I would suggest manually adding
to your user path. That way the executable can find the opencv dll’s when you run it and if you have another project that autodetects the libs using a cmake or other script they will be on the path.
Then set OPENCV_DIR to
I know it doesn’t exist but the headers should be found.
Then you will probably find that your lib’s won’t be detected as they are probably also relative to OPENCV_DIR.

just for the sake of completeness:
C:\workspace\opencv3\build\install includes 4 directories:
bin, with .exe and .dll files
lib, with .lib and some .cmake files
etc, only .xml
include, with opencv2 folder inside, which has .hpp files and some other folders (among these also a directory ‘highgui’ with a different highgui.hpp and a highui_c.h).

Now I wonder if I’m looking at the wrong directory

I don’t know what you mean by fixed, I used Cmake ONLY to compile the openCV library.
Give me just some minutes and I try with your last reply…


Still nothing. This is my last try for the path variable, I thought at least one could work fine… obviously OPENCV_DIR is set to …\install

Forget everything, just add the include directory to your compile options

g++ -o [file] lopencv_highgui -lopencv_core -IC:/workspace/opencv3/build/install/include/

and set OPENCV_DIR to C:/workspace/opencv3/build/install.

C:\Users\epast\Desktop>g++ -o OpenImg OpenImg.cpp -lopencv_highgui -lopencv_core -IC:\workspace\opencv3\build\install\include
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lopencv_highgui
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lopencv_core
collect2.exe: error: ld returned 1 exit status

I would say better, but still not solved

I would check that you can find


from cmd with

where opencv_highgui.lib

Incidentally isn’t it something like opencv_highgui331.lib

If it can’t be found I would verify that the OPENCV_DIR\lib is on the system/user path as I am assuming this is how g++ picks up libs on windows.

Additionally I would ask your professor to correct the instructions as they are for OpenCV 4.

I can’t find
But I succesfully find

However I give up, I spent 8 hours on it today.

@cudawarped thanks for your time, anyway


g++ -o [file] lopencv_highgui331 -lopencv_core331 -IC:/workspace/opencv3/build/install/include/