Using OpenCV in QTCreator (linking issue)
I have a problem with the simplest test program in QTCreator:
CODE:
#include <QtCore/QCoreApplication>
#include <cv.h>
#include <highgui.h>
#include <cxcore.hpp>
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
cv::Mat M(7,7,CV_32FC2,Scalar(1,3));
return 0;
}
.pro
file:
QT -= gui
TARGET = testopencv
CONFIG += console
CONFIG -= app_bundle
INCLUDEPATH += C:/OpenCV2_1/include/opencv
TEMPLATE = app
LIBS += C:/OpenCV2_1/lib/cxcore210d.lib \
C:/OpenCV2_1/lib/cv210d.lib \
C:/OpenCV2_1/lib/highgui210d.lib\
C:/OpenCV2_1/lib/cvaux210d.lib
SOURCES += main.cpp
I tried using -L and -l as LIBS += -LC:/OpenCV2_1/lib -lcxcored
And in the .pro
file:
QMAKE_LIBDIR += C:/OpenCV2_1/lib/Debug LIBS += -lcxcore210d \ -lcv210d \ -lhighgui210d
Errors:
debug/main.o:C:\griskin\test\app\testopencv/../../../../OpenCV2_1/include/opencv/cxcore.hpp:97: undefined reference to cv::format(char const*, ...)'
Can anyone help me? Thanks!
It works in Visual Studio, but I need it to work in QTCreator ..
a source to share
Using OpenCV from QTCreator couldn't be easier. I have a simple simple way to do it here.
http://www.barbato.us/2010/09/20/using-opencv-within-qtcreator-in-windows/
Good luck and have fun with OpenCV
a source to share
Qt uses the MinGW compiler and linker. It will happily bind OpenCV .lib
when you use the C interface. However, due to the ABI, problems won't bind C ++ modules.
You will either have to limit yourself to only C interfaces (i.e. no cv::Mat
), or get OpenCV to compile with MinGw (or compile Qt to / from VS). Also see this thread .
a source to share
This is what my .pro file looks like
INCLUDEPATH += C:\\opencv\\release\\install\\include\
LIBS += -LC:\\opencv\\release\\install\\bin \
-lopencv_core240 \
-lopencv_highgui240 \
-lopencv_imgproc240 \
-lopencv_features2d240 \
-lopencv_calib3d240 \
and replace
#include <cv.h>
from
#include <opencv/cv.h>
The above .pro file works perfect for me. I have used mingw to compile OpenCV and use the mingw compiler toolchain in Qt.
a source to share
It seems that QtCreator cannot find the lib files. Try to specify the include and libs file as follows.
INCLUDEPATH += C:/OpenCV2_1/build/include/
LIBS += C:/OpenCV2_1/build/gpu/x86/lib/cxcore210d.lib
you should refer to build if you are using opencv preview.
(I recommend the pre-build version if you are not familiar with opencv)
a source to share