OpenCV 使用 Eclipse 和 CDT

发布于 2024-12-22 23:30:59 字数 341 浏览 2 评论 0原文

我一直使用 QtCreator for OpenCV,但是与朋友开始的一个新项目需要使用 eclipse 来完成。

我做了我通常用 QtCreator 做的所有事情,但我遇到了一个奇怪的问题。尽管我在尝试编译时确实设置了包含路径(/home/opencv/include),但我收到了缺少标头的错误(即 opencv2/core/core.hpp)。在包含标签下的项目资源管理器中,唯一出现的标题是包含目录第一级中的标题。这意味着 cdt 不会递归地包含标头。

这是一个错误还是我必须包含每个目录?

在此处输入图像描述

I was always using QtCreator for OpenCV but a new project started with a friend needs to be done with eclipse.

I did all things I usually do with QtCreator but I am facing a strange problem. Although I did set the include path (/home/opencv/include) when I try to compile I get errors for missing headers (i.e opencv2/core/core.hpp). In the project explorer under include tag the only headers appear are the ones in the first level of the included directory. This means that cdt does not include headers recursively.

Is this a bug or I have to include every single directory?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七禾 2024-12-29 23:30:59

我昨天也遇到了同样的问题。它搜索了整个论坛,但没有人能回答我。最后我意识到我正在对整个项目进行包含,并且项目的包含文件源文件“source.txt”的包含文件不同。 cpp”(对于 eclipse,因为对于 VisualStudio 来说是相同的)。

在此处输入图像描述

因此,尝试右键单击 .cpp 文件并包含其目录。不管怎样,如果你告诉我你正在使用哪个版本的 OpenCV,我可以告诉你如何包含文件的更多方面,以防你继续遇到麻烦。

我希望它有帮助。当您收到有关缺少标头的错误时,始终与包含相关。至少我的情况是这样的。

I had the same problem yesterday. It searched all around forums but nobody could answer me. Finally I realized that I was doing the include for the whole project and including files for the project is not the same as including files for the source file "source.cpp" (for eclipse, because for VisualStudio it is the same).

enter image description here

So try to rightclick on the .cpp file and include the directories for it. Anyway, if you tell me which version of OpenCV you're using I can tell you more aspects of how to include files in case you keep having troubles.

I hope it helps. When you get errors about missing headers is always related to include. At least it happened to be like this in my case.

分開簡單 2024-12-29 23:30:59

如果 Eclipse 中的包含路径是 /home/opencv/include ,我们假设该目录中有 2 个文件夹:opencvopencv2

在源代码中,您必须将标头引用为:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

这对您有意义吗?

不过,有一些教程可以帮助您配置 Eclipse

If the include path in Eclipse is /home/opencv/include , we assume that inside this directory you have 2 folders: opencv and opencv2.

On your source code you must reference the headers as:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

Does that makes sense to you?

Nevertheless, there are several tutorials that can help you configure Eclipse.

多孤肩上扛 2024-12-29 23:30:59

我也有这个问题。我认为你需要做的是包含路径 opencv/build/include,而不是 opencv/include。这是所有头文件所在的位置。

I had this problem, too. I think what you need to do is to include the path opencv/build/include, not opencv/include. That's where all the header files are.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文