Ask Your Question

Where are the correct include directories for OpenCV projects using a local build / self-build of OpenCV?

asked 2013-10-27 05:39:58 -0500

dumbledad gravatar image

updated 2013-10-27 12:53:57 -0500

I'm trying to debug a frustrating problem whereby I cannot load video files in OpenCV. One suggestion is to abandon the OpenCV pre-built libraries and instead build OpenCV on the same machine as the failing project.

That is what I am now trying to do.

In the OpenCV Quick Start about how to build applications with OpenCV inside the Microsoft Visual Studio one important step is to add the additional include directories to the project property sheet by opening the project's property pages, navigating to Configuration Properties -> C/C++ -> General -> Additional Include Directories. Using the pre-built distribution I am advised to add the directory C:\OpenCV2.4.6\build\include and indeed inside that directory are sub-directories opencv and opencv2. One of the files my project (like most OpenCV projects) will need is highgui.hpp from the line

#include "opencv2/highgui/highgui.hpp"

In the pre-built OpenCV distribution highgui.hpp ends up in C:\OpenCV2.4.6\build\include\opencv2\highgui and is thus correctly picked up at compile time because of the additional include directory.

Having generated with CMake and built with Visual Studio 2012 the latest version of OpenCV on my machine (though perhaps unsuccessfully) I cannot find highgui.hpp. It is not in C:\Users\timregan\Documents\GitHub\opencv\build\include (in fact there are no sub-directories opencv nor opencv2 in there). It is in C:\opencv-2.4\modules\highgui\include\opencv2\highgui.

What step, flag, etc. did I omit in order to generate place it correctly on my machine? Why are the opencv and opencv2 sub-directories missing completely from C:\Users\timregan\Documents\GitHub\opencv\build\include after I have generated and built OpenCV?

(N.B. I'm using CMake 2.8.12 and Visual Studio 2012 on a Windows 8 machine.)

edit retag flag offensive close merge delete


Thanks @berak, that works. If you copy that advice into an answer I'll mark it as such.

dumbledad gravatar imagedumbledad ( 2013-10-28 03:58:31 -0500 )edit

Hi, i'm facing the same issue, however i'm on a mac, and there is no INSTALL project that gets generated in my opencv folder. What alternate steps should i follow on the mac? Or should i also have had the INSTALL project to compile if things had gone correctly? (i just ran make and make)

sachi gravatar imagesachi ( 2016-03-03 08:59:18 -0500 )edit

@sachi - isn't it just make install then ?

berak gravatar imageberak ( 2016-03-03 09:02:56 -0500 )edit

According to me make install will create symlinks of my headers and libs into usr/local and usr/include (right?), but i don't want opencv to be installed globally on my system, just the folder structure to be the same as it would have been had i installed it via brew into usr/local/Cellar, i.e., with the opencv/include/opencv2 folder containing the HPPs of all the other modules. Right now i just have opencv.hpp(within the opencv2 folder) and a couple of cmake and make files in my include folder .

sachi gravatar imagesachi ( 2016-03-03 09:13:26 -0500 )edit

you can specify the install path with cmake (CMAKE_INSTALL_PREFIX), and sure, you can redirect that to your home folder or such

berak gravatar imageberak ( 2016-03-03 09:18:43 -0500 )edit

Okay solved, thanks!

sachi gravatar imagesachi ( 2016-03-03 09:31:41 -0500 )edit

Hi, setting the install path to a non standard location gives an error in Xcode when i link the .dylibs in my project. In my case the error is: dyld: Library not loaded: lib/libopencv_calib3d.3.1.dylib Reason: Image not found . I have given the relevant search paths w.r.t where the libraries are placed. Should i change the value of INSTALL_NAME_DIR from lib to ${CMAKE_INSTALL_PREFIX}/lib?

sachi gravatar imagesachi ( 2016-03-04 03:31:46 -0500 )edit

@sachi, can't help. and since this was a win-related question, - rather start your own, now ?

berak gravatar imageberak ( 2016-03-04 03:33:43 -0500 )edit

Yep,shall do that, thanks.

sachi gravatar imagesachi ( 2016-03-04 04:01:37 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-10-27 13:02:27 -0500

berak gravatar image

after building, you run the INSTALL project. that copies anything(headers,libs,dlls) to some folder (probably called 'install', you can change that from cmake-gui).

edit flag offensive delete link more

Question Tools


Asked: 2013-10-27 05:39:58 -0500

Seen: 5,564 times

Last updated: Oct 27 '13