简体   繁体   English

#包括<opencv2/opencv.hpp>在 VS 2013 中不起作用

[英]#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以便您的更改同时适用于ReleaseDebug构建模式,或者您应该为每个构建类型设置适当的单独配置(设置Additional Include Directories等)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:opencv2/opencv.hpp:没有这样的文件或目录#include“opencv2/opencv.hpp” - fatal error: opencv2/opencv.hpp: No such file or directory #include "opencv2/opencv.hpp" 错误C1083无法在VS 2015中打开包含文件:&#39;opencv2 \\ opencv.hpp&#39; - Error C1083 Cannot open include file: 'opencv2\opencv.hpp' in VS 2015 VS Code 无法打开源文件“opencv2/opencv.hpp” - VS Code cannot open source file “opencv2/opencv.hpp” opencv2 / opencv.hpp:使用Eclipse IDE时没有这样的文件或目录 - opencv2/opencv.hpp: No such file or directory using Eclipse IDE 简单地包括<opencv2 opencv.hpp>导致链接错误</opencv2> - Simply including <opencv2/opencv.hpp> results in linking error <opencv2/opencv.hpp> ,<opencv2/imgproc.hpp> ,<opencv2/highgui.hpp> 无此文件或目录 - <opencv2/opencv.hpp>, <opencv2/imgproc.hpp>, <opencv2/highgui.hpp> no such file or directory 介子和 OpenCV: fatal error: opencv2/opencv.hpp: No such file or directory - Meson and OpenCV: fatal error: opencv2/opencv.hpp: No such file or directory Visual Studio 2012:“opencv2/opencv.hpp”:没有这样的文件或目录 (C1083) - Visual Studio 2012: 'opencv2/opencv.hpp' : No such file or directory (C1083) 通过 vcpkg 安装 package 导致“opencv2/opencv.hpp:没有这样的文件或目录”错误 - Installing package via vcpkg causing a "opencv2/opencv.hpp: No such file or directory" error 无法在 Visual Studio 2019 中打开源文件 opencv2/opencv.hpp - cannot open source file opencv2/opencv.hpp in visual studio 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM