简体   繁体   中英

OpenCV using Eclipse with 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 (ie 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?

在此输入图像描述

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).

在此输入图像描述

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.

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM