6

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.

4
  • is there a file named opencv2.hpp in C:\OpenCV3\build\include\opencv2 Commented Aug 26, 2015 at 7:47
  • If you are using "C:\OpenCV3\build\include\opencv2" in additional directories, shouldn't you just include <opencv2.hpp> instead of <opencv2/opencv2.hpp ? Commented Aug 26, 2015 at 7:54
  • Shouldn't it be <opencv2/opencv.hpp> instead? Commented Aug 26, 2015 at 13:27
  • That was a typo, here is what I wrote: #include <opencv2/opencv.hpp> (using copy, paste) Commented Aug 26, 2015 at 16:55

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

You suggestion is the very first thing I tried, and it does not work.
hm. that's weird... did you followed the steps in this tutorial: docs.opencv.org/3.0-beta/doc/tutorials/introduction/… ? The other modules are working fine? core, imgproc, highgui...?
Have not tried the other modules, but surely this is an issue with VS2013 Community Edition. I'm wondering whether it has deliberate restrictions.
That's a great tutorial, thanks, I don't know if it fixes my problem, but I am learning a lot.
Well, there is a kind of workaround: copy the opencv2 directory tree into the source project, and replace #include <...> by #include <...> every where. Makes me wonder if VS2013 community edition is crippled or buggy.
|
1

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.

1 Comment

Yep this worked for me - so weird as this wan't explained in the tutorial I am watching in Pluralsight. Getting Started with OpenCV in .NET by Kobi Hikri. Drives me mad when there seems to be missing information in a tutorial (of all things!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.