PDA

View Full Version : Build Opencv 3.2 code in Qt Creator4.3.1 with MSVC2015 64bit compiler .



Ziri
17th August 2017, 05:55
I downloaded Qt creator community and Opencv 3.2

I created new project and built release version with MSVC2015 64bit compiler . (it works fine)

I added to .pro file (Opencv library include&libs):

INCLUDEPATH += -L"C:\\.......\\prebuilt\\include\\opencv2"

CONFIG(release ,debug|release)
{
LIBS += -l"C:\\........ \\prebuilt\x64\vc14\lib"
LIBS += opencv_world320

}


I included :
#include <opencv2/imgproc.hpp> in mainWindow.h

When I build I get this error :

fatal error C1083: Cannot open include file: 'opencv2/imgproc.hpp': No such file or directory
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -DWIN32 -DWIN64 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\untitled -I. -Il-C:\Users\lenovo\Documents\prebuilt\include -I..\..\..\..\Qt\5.9.1\msvc2015_64\include -I..\..\..\..\Qt\5.9.1\msvc2015_64\include\QtWidget s -I..\..\..\..\Qt\5.9.1\msvc2015_64\include\QtGui -I..\..\..\..\Qt\5.9.1\msvc2015_64\include\QtANGLE -I..\..\..\..\Qt\5.9.1\msvc2015_64\include\QtCore -Irelease -I. -I..\..\..\..\Qt\5.9.1\msvc2015_64\mkspecs\win32-msvc -Forelease\ @C:\Users\lenovo\AppData\Local\Temp\moc_mainwindow .obj.4632.500.jom
moc_mainwindow.cpp


What I am doing wrong ?

Thank you .

high_flyer
17th August 2017, 11:05
You are using the wrong include flag.
You are using -L (which is for search library directory).
You should use -I (that is a capital i)
INCLUDEPATH += -I"C:\\.......\\prebuilt\\include\\opencv2"
And vice versa for the libraries:
LIBS += -L"C:\\........ \\prebuilt\x64\vc14\lib" <<--- -L instead of -I
LIBS += -lopencv_world320.lib <<--- note the changes, you have to add a -l (that is a lower case L) and I think you need to add the *.lib extension too.

d_stranz
17th August 2017, 20:13
#include <opencv2/imgproc.hpp> in mainWindow.h

To add to what high_flyer said, if this is how you are including the opencv2 header files, then your -I directive needs to end with the "include" path, not "include\\opencv2".