QT Creator在标题中找不到OpenCV子标题时出错 [英] QT Creator has Error Locating OpenCV Sub-Headers Within Headers
问题描述
我正在尝试将一直在研究的OpenCV项目集成到Qt GUI中.话虽如此,我认为最简单的方法是将OpenCV集成到Qt Creator中,而不是继续在Visual Studio 2015中工作.
I am trying to integrate an OpenCV project I have been working on into a Qt GUI. That being said, I figured the most simplistic way of going about that was to integrate OpenCV into Qt Creator, rather than continue to work in Visual Studio 2015.
但是,我遇到了一个问题.我的项目无法编译,因为它无法在我调用的任何头文件中找到子头文件的目录.
However, I have ran into a problem. My project will not compile because it cannot find the directory for the sub-header files within whatever header file I call upon.
例如,如果包含 highgui.hpp 并尝试编译我的程序,则会抛出错误,指出没有这样的文件或目录 opencv2/core/cvdef.h , opencv2/core/base.hpp 或 opencv2/core/cvstd.hpp .
For example, if include highgui.hpp and try to compile my program, it will throw an error stating that there is no such file or directory for opencv2/core/cvdef.h, opencv2/core/base.hpp or opencv2/core/cvstd.hpp.
附有图片以更清楚地说明我在说什么:
Attached are pictures to more clearly demonstrate what I'm saying:
- http://imgur.com/a/Bsg2L
- http://imgur.com/a/sVQMG
我使用CMake使用MinGW(64位)生成必要的makefile,然后使用 mingw32-make 对其进行编译.之后,我运行了 mingw32-make install 将这些文件安装到我的系统中. (仅供参考,这包括将系统路径变量编辑为MinGW安装文件夹中 gcc 和 g ++ 的位置.)
I used CMake to generate the necessary makefiles with MinGW (64-Bit), then compiled them using mingw32-make. After that I ran mingw32-make install to install said files to my system. (FYI, this includes editing the system path variable to the locations of gcc and g++ within the MinGW install folder).
在QT Creator中,我在 QT_TEST.pro 文件中设置了以下路径:
Within QT Creator, I set the following paths in my QT_TEST.pro file:
INCLUDEPATH += C:/Users/micha/Documents/OpenCV/opencv/mingw-release/install/include/opencv2
LIBS += C:/Users/micha/Documents/OpenCV/opencv/mingw-release/install/x64/mingw/bin
LIBS += -lopencv_core310 -lopencv_highgui310 -lopencv_imgproc310
根据我看过的每个教程,这就是所有需要的设置.
According to every tutorial I have watched, that was all the setup needed.
- 设置路径变量以包含头文件和子头文件的位置.
- 在我的 QT_TEST.pro 文件中的子标题路径包括为 LIBS 和 INCLUDEPATH .
- 重新启动计算机.
- Setting my path variables to include locations of header and subheader files.
- Including the path for the subheaders within my QT_TEST.pro file as LIBS and INCLUDEPATH.
- Restarting my computer.
从这里我不知道要去哪里.我真的很想为我的项目创建一个不错的UI,而Qt似乎是正确的方法.您会提供任何帮助解决我的问题的帮助,将不胜感激.
From here I don't know where to go. I would really like to create a nice UI for my project, and Qt seems like the right way to go. Any help you could offer to help fix my problem would be much appreciated.
推荐答案
我非常感谢您提供的所有有用信息,并尝试了您提出的所有建议,并使用各种不同的设置从源代码重新编译了OpenCV,但不幸的是,我无法获得库,以便在使用Windows时正确链接到Qt Creator中.我认为这是我使用的计算机所特有的问题.
I appreciate all of your helpful responses and tried everything you suggested as well as recompiled OpenCV from source with all kinds of different settings, but unfortunately I could not get the libraries to correctly link in Qt Creator while using Windows. I assume it's a problem specific to the machine I'm using.
话虽这么说,我用Manjaro Linux覆盖了Windows(我知道,这是一种剧烈的举动),现在链接库没有问题.在我的.pro文件中,我包括了以下几行:
That being said, I overwrote Windows with Manjaro Linux (I know, kind of a drastic move), and now have no problem linking libraries. In my .pro file, I included these lines:
INCLUDEPATH += /usr/local/include/opencv2
LIBS += `pkg-config opencv --libs`
现在一切都很好.再次感谢大家的帮助.如果可以的话,我会将赏金平均分配给该线程中的每个人.
Everything is working great now. Again, thank you all for your help. If I could, I would distribute the bounty evenly to everyone in this thread.
这篇关于QT Creator在标题中找不到OpenCV子标题时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!