Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Login
Home / Qt Development / General and Desktop / [solved] Impossible to include OpenCV path
Gmember
I am trying to configure a new Qt Creator project in order to use OpenCV 3.1.0. I downloaded the precompiled binaries from
http://opencv.org/downloads.html, and I created an empty Qt gui project. The problem is that qmake doesn't find the opencv headers, no matter how I
try to include their path. Here is my last attempt:
QT
+= core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = App_v1
TEMPLATE = app
INCLUDEPATH += C:/OpenCV-3.1.0/opencv/build/include
LIBS += -LC:\OpenCV-3.1.0\opencv\build\x64\vc14\lib
LIBS += -lopencv_world310d
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
<opencv2/core/core.hpp>
<opencv2/highgui/highgui.hpp>
<opencv2/imgproc/imgproc.hpp>
"mainwindow.h"
<QApplication>
When I try to compile this, I get: "C1083: Cannot open include file: 'opencv2/core/core.hpp": No such file or directory
QApplication a(argc, argv);
(btwMainWindow
thanks Qt Creator
for not letting me select and copy the text of the error. Sorry I digress...)
w;
I amw.show();
sure that the path is correct, and the funny thing is that when I type cv:: the auto completion finds and lists the classes and functions in the cv
namespace.... what is going on here?
return a.exec();
EDIT: I forgot to mention that OpenCV works perfectly with Visual Studio, so I know that it is installed correctly.
}
VRonin
I think the problem is that you have . (the dot) in the path.
try replacing
INCLUDEPATH += C:/OpenCV-3.1.0/opencv/build/include
with
INCLUDEPATH += "C:/OpenCV-3.1.0/opencv/build/include"
"La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
~Napoleon Bonaparte
Gmember
Gmember @VRonin
@VRonin Thank you for your reply. I tried, but it doesn't have any effect. I do not think that dots cause this problem (or at least, it is not mentioned
anywhere). Apparently you need quotes for path with spaces only.
0
VRonin
This is strange, the .pro looks correct. if C:/OpenCV-3.1.0/opencv/build/include/opencv2/core/core.hpp definitely exists then try clean your project
before building, it might be just some leftovers
"La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
~Napoleon Bonaparte
Gmember @VRonin
@VRonin Yep that was the problem, thank you. I didn't think about cleaning before rebuilding, I believe that it should be automatic... Sadly, now I have
another problem:
:-1: error: LNK1104: cannot open file 'opencv_world310d.lib'
and again, I know that the name of the file and the path are correct
VRonin
try replacing
LIBS += -LC:\OpenCV-3.1.0\opencv\build\x64\vc14\lib
LIBS += -lopencv_world310d
with
LIBS += "C:/OpenCV-3.1.0/opencv/build/x64/vc14/lib/opencv_world310d.lib"
Gmember @VRonin
@VRonin Thank you again, now it works. I also had to copy the dlls from Qt and opencv into the program folder, since it wouldn't find them otherwise.
VRonin
dll paths do not influence the build so they are not included in qmake. if you use QtCreator in the right bar select project and in the build and run tab,
select the run subtab and you can customise the run environment adding the paths of the dlls to the run environment PATH
otherwise you can use the INSTALLS of qmake to deploy all the binaries where you need them
2
"La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
~Napoleon Bonaparte
222
POSTS
VIEWS
Log in to reply