Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#include <opencv2/opencv.hpp> not working in VS 2013

Tags:

c++

opencv

I have VS2013 community edition, I just installed OpenCV in a directory c:\openCV3 and there is a build subfolder with an include subfolder of that etc, everything looks normal. So I create an empty project with the line#include <opencv2/opencv.hpp> but I get

Error 1 error C1083: Cannot open include file: 'opencv2/opencv.hpp': No such file or directory d:\devt\cplusplus\opencv\test1\test1\source.cpp 1 1 Test1

However I have modified my project's additional include directories to this:

C:\OpenCV3\build\include\opencv;C:\OpenCV3\build\include\opencv2;C:\OpenCV3\build\include;%(AdditionalIncludeDirectories)

But nothing doing, the mistake does not go away. Pretty much the same question has been asked before but the answers do not work for me.

Update: I right clicked on <opencv2/opencv.hpp> and, in the popup menu chose OpenDocument. I got the following message box: File Not Found

What I found surprising is that there is no mention of my set of additional include directories.

like image 665
user1741137 Avatar asked Sep 26 '22 22:09

user1741137


2 Answers

Instead of use the includes C:\OpenCV3\build\include\opencv and C:\OpenCV3\build\include\opencv2, try to use C:\OpenCV3\build\include\. When you call an include you're already telling the folder you are using:

#include <opencv2/opencv.hpp>

In that case, VS is searching opencv2/opencv.hpp in folder opencv2... VS must search in the folder include, so it will found opencv2/opencv.hpp...

(or you can try to modify your include to "#include "

Hope it helps.

like image 102
chr0x Avatar answered Nov 15 '22 09:11

chr0x


I faced similar issues with VS2013 - it felt that Additional Include Directories was not working. However, as I figured out later, when editing

Project -> Properties -> C/C++ -> General -> Additional Include Directories

I didn't pay attention on the selected Configuration: on the top right corner of the properties panel (Debug/Release etc.).

You can choose All Configurations so that your changes apply to both Release and Debug building modes, or you should setup proper individual configurations (set Additional Include Directories etc.) per build type.

like image 28
khkarens Avatar answered Nov 15 '22 09:11

khkarens