Is it configuration problem of opencv3.10 with qt 5.5? Showing Error "undefined reference to `cv::imread(cv::String const&, int)"
-
Hello I want to implement sobel operator, so for that i need to read matrix of the input image. I tried to perform with
cv::imread()
but i am getting the errorundefined reference to `cv::imread(cv::String const&, int)
this is my code below
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); Mat src, dst; /// Load an image src = cv::imread("C:\\Users\\Prashanth KUMAR\\Pictures\\PhotoGrid_1448276690562.jpg"); namedWindow("initial"); imshow("initial", src); waitKey(); } MainWindow::~MainWindow() { delete ui; }
testSobel.pro
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = TestSobel TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui
I read in some posts that it is the problem of including opencv libraries in Qt.
But my Qt Build environment already has an opencv directory
here is the screenshot below
https://drive.google.com/file/d/0B6gtKf78_zVOLWFPWFFzRk5EeXc/view?usp=sharingOr is there any other way to link opencv 3.10 with Qt Creator 5.5 in windows?
-
Hi,
You need to tell your compiler that you want to link against the OpenCV libraries otherwise it won't know anything about them.
-
What did you try ?
What error did you get ?
What compiler are you using ? -
@SGaist I downloaded and extracted openCV. Later installed Qt. Added the directories
C:\Qt\5.5\mingw492_32\bin
C:\opencv\build\x86\vc12\bin
to the path in Environment variables.Later downloaded CMake and installed it and added its path too.
Created an empty folderopencv-mingw
In CMake i selected
the sourcecode Directory asC:\Qt\Tools\mingw492_32\bin
Buid the binary inC:/opencv-mingw
and hit configure buttonSelected
MinGW Makefiles
from dropdown menu. Then it asked to specify native compilers
SpecifiedC:/Qt/Tools/mingw491_32/bin/gcc.exe
for C
specifiedC:/Qt/Tools/mingw491_32/bin/g++.exe
for C++
and hit finishIT GAVE ME ERROR
Error in configuration process, Project files may be invalid
-
You are trying to link a Visual Studio build of OpenCV with a MinGW build of Qt. That won't work.
If already available in your package, use the MinGW version. Otherwise you have to compile OpenCV by hand.