[英]#include <opencv2/opencv.hpp> not working in VS 2013
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.我有 VS2013 社区版,我刚刚在目录 c:\\openCV3 中安装了 OpenCV,并且有一个 build 子文件夹,其中包含一个包含子文件夹等,一切看起来都很正常。 So I create an empty project with the line
#include <opencv2/opencv.hpp>
but I get所以我用
#include <opencv2/opencv.hpp>
行创建了一个空项目,但我得到
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
错误 1 错误 C1083:无法打开包含文件:'opencv2/opencv.hpp':没有这样的文件或目录 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.更新:我右键单击
<opencv2/opencv.hpp>
,然后在弹出菜单中选择 OpenDocument。 I got the following message box:我收到以下消息框:
What I found surprising is that there is no mention of my set of additional include directories.我发现令人惊讶的是,没有提到我的一组附加包含目录。
Instead of use the includes C:\\OpenCV3\\build\\include\\opencv and C:\\OpenCV3\\build\\include\\opencv2, try to use C:\\OpenCV3\\build\\include\\
.不要使用包含 C:\\OpenCV3\\build\\include\\opencv 和 C:\\OpenCV3\\build\\include\\opencv2,尝试使用
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...在这种情况下,VS在文件夹opencv2中搜索opencv2/opencv.hpp... VS必须在文件夹include中搜索,所以它会找到opencv2/opencv.hpp...
(or you can try to modify your include to "#include " (或者您可以尝试将您的包含修改为“#include”
Hope it helps.希望能帮助到你。
I faced similar issues with VS2013 - it felt that Additional Include Directories
was not working.我在 VS2013 中遇到了类似的问题 - 感觉
Additional Include Directories
不起作用。 However, as I figured out later, when editing然而,正如我后来发现的,在编辑时
Project -> Properties -> C/C++ -> General -> Additional Include Directories
项目 -> 属性 -> C/C++ -> 常规 -> 附加包含目录
I didn't pay attention on the selected Configuration: on the top right corner of the properties panel ( Debug/Release
etc.).我没有注意选择的配置:在属性面板的右上角(
Debug/Release
等)。
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.您可以选择
All Configurations
以便您的更改同时适用于Release
和Debug
构建模式,或者您应该为每个构建类型设置适当的单独配置(设置Additional Include Directories
等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.