Where are the header files?

I’ve successfully compiled OpenCV with CUDA and cudnn on Windows with Visual Studio 2022.

I’ve found the .lib’s, which are under lib/Release, but there are no header files under include/ …

Was there a cmake parameter i should’ve set for my build to have copied the header files from the source code?

cmake should have generated an INSTALL project,
run build that , and all you need will be copied to an ‘install’ folder
(or whatever you set CMAKE_INSTALL_PREFIX to)

Thank you!

Now i’m running into another problem which is getting access denied on Visual Studio when hitting Run the project.

I’ve already added the project’s directory to my anti virus exceptions list, but still getting that error for some reason…

that’s because regular users don’t have permissions in C:\Program Files

look closely at the output. it’ll tell you the directory that it wants to copy files into.

open explorer in C:\Program Files and create the directory that the INSTALL target wants to copy files into. explorer will ask you for confirmation.

now that you created the directory, the files can be copied by the INSTALL target.

I’ve tried running Visual Studio as Administrator.

Visual Studio’s console outputs the following:

Build started...
1>------ Build started: Project: gen_opencv_python_source, Configuration: Release x64 ------
========== Build: 1 succeeded, 0 failed, 207 up-to-date, 0 skipped ==========
========== Build started at 8:56 PM and took 04.514 seconds ==========
Unable to start program 'D:\OpenCV\opencv-build\x64\Release\ALL_BUILD'.

Access is denied.

I’ve also added OpenCV’s build directory to my Anti Virus exception list, so i doubt it’d be that…

you are not supposed to do that. never ever. that’ll cause so much trouble. you can’t imagine.

and don’t do that. that does nothing.

build the INSTALL project (target).

how did you manage that? it’s not executable, it’s a project/target that needs to be built.

I think ALL_BUILD is the default target and he pressed the green arrow next to “Local Windows Debugger” which built the target and tried to execute it.

Right click INSTALL under CMakeTargets and select Build.

True, i shouldn’t run Visual Studio as Administrator.

I use an account with no administrator rights on my computer, not because it’s not my computer and i can’t access the administrator account, but because it’s something that i learnt about security off Unix-like systems.

I’m not used to working with Visual Studio, i will be giving your suggestion a try since i’ve managed to get farther with Windows than i did with Debian. Ubuntu 20.04 was somehow installing CUDA and cudnn correctly. Ubuntu 22.04 doesn’t even boot properly on my computer. But that’s beyond the scope of this thread and forum.

I’ll give your suggestions a try and then i’ll post whether i managed it or not.

How i managed the Release/ALL_BUILD , it was the default when i started Visual Studio as cudawarped mentioned.

Alright, i’ve hit build on INSTALL and it outputs the following

Build started...
1>------ Build started: Project: gen_opencv_python_source, Configuration: Release x64 ------
2>------ Build started: Project: INSTALL, Configuration: Release x64 ------
2>-- Install configuration: "Release"
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ippicv-readme.htm
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ippicv-EULA.rtf
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ippicv-third-party-programs.txt
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ippiw-support.txt
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ippiw-third-party-programs.txt
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ippiw-EULA.rtf
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/flatbuffers-LICENSE.txt
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/opencl-headers-LICENSE.txt
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ade-LICENSE
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ffmpeg-license.txt
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/licenses/ffmpeg-readme.txt


2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/lbpcascades/lbpcascade_frontalface.xml
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/lbpcascades/lbpcascade_frontalface_improved.xml
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/lbpcascades/lbpcascade_profileface.xml
2>-- Up-to-date: D:/OpenCV/opencv-build/install/etc/lbpcascades/lbpcascade_silverware.xml
2>-- Up-to-date: D:/OpenCV/opencv-build/install/x64/vc17/bin/opencv_annotation.exe
2>-- Up-to-date: D:/OpenCV/opencv-build/install/x64/vc17/bin/opencv_visualisation.exe
2>-- Up-to-date: D:/OpenCV/opencv-build/install/x64/vc17/bin/opencv_interactive-calibration.exe
2>-- Up-to-date: D:/OpenCV/opencv-build/install/x64/vc17/bin/opencv_version.exe
2>-- Up-to-date: D:/OpenCV/opencv-build/install/x64/vc17/bin/opencv_version_win32.exe
2>-- Up-to-date: D:/OpenCV/opencv-build/install/x64/vc17/bin/opencv_model_diagnostics.exe
========== Build: 2 succeeded, 0 failed, 207 up-to-date, 0 skipped ==========
========== Build started at 6:36 AM and took 05.261 seconds ==========

But when hitting Run it still defaults to running ALL_BUILD…

visual studio default project


I’ve managed to switch projects under Configure Startup Projects, now it outputs the following:

Build started...
1>------ Build started: Project: gen_opencv_python_source, Configuration: Release x64 ------
2>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
2>Project not selected to build for this solution configuration 
========== Build: 1 succeeded, 0 failed, 207 up-to-date, 1 skipped ==========
========== Build started at 6:45 AM and took 01.352 seconds ==========

And gives me the same error of access denied when running the project.

What are you trying to run?

OpenCV is a library you can’t run it.

You can run the test/perf/sample programs but that’s it.

Your original question was regarding the header files, which implies you want to write your own program which links against the library, but your post above implies you want to do something with python which is it?

I’m trying to run the default INSTALL with only the CUDA flags enabled in cmake.

I’m not however getting any hints where INSTALL wants to copy the files to on Visual Studio’s terminal output, only the access is denied error… I’ve already set INSTALL as the default project in Visual Studio, but running it only throws the error and that output during build that i’ve posted previously.

Your original question was regarding the header files, which implies you want to write your own program which links against the library

Yes that’s correct regarding what i want to do.

Okay, i believe i figured it out.

There’s a folder named install inside opencv’s build directory, with bin, etc, include and x64 folders. The include folder contains the header files, whilst x64\vc17\lib contains the libraries.

OK so now I understand the confusion.

You are confusing running with building. You can’t run all CMake targets, you should be able to build all of them but then you can only run executables. That is you build a library and a target which INSTALL’s OpenCV.

Visual studio lets you run all targets as they appear as projects but all that does is execute whatever is given in
Properties->Debugging->Command, which defaults to $(TargetPath).

I think “running” a build/install is an acceptable choice of words.

opencv by default installs all the dlls and libs etc… into that “install” dir under its build directory. that is configurable via cmake. that location is okay to keep.

the python stuff is supposed to be sent into whatever python was found by cmake.

at least, I think so. it’s been a while since I built opencv myself. there might be a different target that copies the files to Python. if you hadn’t removed part of the log of your INSTALL build, I might be able to tell.

you’ll want to find a file named cv2.pyd or cv2.cp39-win_amd64.pyd (or cp312 or whatever python you have). you can copy that yourself into the right place inside your python installation.

here’s some mention of copying this file: OpenCV: Install OpenCV-Python in Windows

instead of the single “world” dll, you probably have a bunch of individual module dlls. you can either copy those, or extend your system PATH to include the directory where they do live. I’d suggest that be their location in the build/install/ directory (x64/vc??/bin).