Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012: 'opencv2/opencv.hpp' : No such file or directory (C1083)

This question was asked several times, there are some answers, but this problem is more specific, the additional directories path is set correctly (files are found).

Nevertheless building my project i get the following error:

 fatal error C1083: Cannot open include file: 
 'opencv2/opencv.hpp': No such file or directory

but i can right click on the file and open it in visual studio 2012?

File can be found without a problem

I tried:

1) specifying the full path: WORKS!

#include <D:\frameworks\opencv_2_4\build\include\opencv2\opencv.hpp>

2) Putting the file to C:\ Doesn't Work! (add. directories added)

3) Empty project with the same include syntax. (add. directories added). WORKS!

4) I've configured a VS2010 Version of the same project with CMake, and i have there the same problems.

Any hints what could be causing this error?

like image 267
user1767754 Avatar asked Feb 01 '14 16:02

user1767754


4 Answers

If you put the headers within your project. As @CalaveraLoco's answer. Could using the relative path to access the header.

But it's better to include the project folder path into your project settings.

  1. Open Properties of the project.
  2. Select C/C++
  3. Select General
  4. Add $(ProjectDir); into Addition Include Directories
like image 186
JustWe Avatar answered Nov 12 '22 08:11

JustWe


project property => C/C++ => General => Additional include Directories => "put the address of library from your openCV folder eg: C:\opencv\build\include As shown in the picture below enter image description here

like image 44
hab Avatar answered Nov 12 '22 07:11

hab


Open Configuration Properties > C/C+ + > General , and edit the field Additional Include Directories to add these 3 paths (for the headers): C:\OpenCV2.3\build\include\opencv C:\OpenCV2.3\build\include \opencv2 C:\OpenCV2.3\build\include

like image 13
Tom J Muthirenthi Avatar answered Nov 12 '22 07:11

Tom J Muthirenthi


In my case the problem had to do with exported classes.

I have 2 VS projects. Let's name them A and B. Project A uses classes from project B; and project B uses classes of OpenCV. Project A didn't use (neither link) OpenCV. (as you can imagine project A uses openCV throught project B).

But if any of the exported classes of B (used by A) had a private member of type OpenCV (cv::Mat, for example), in that case, the error C1083 appeared, although i had correctly linked openCV in project B.

My solution was to be carefull with the includes in the *.hpp files of the exported classes of project B.

Hope it's usefull.

like image 1
S. Huerta Avatar answered Nov 12 '22 07:11

S. Huerta