undefined reference to `cvLoadImage'
I installed "libopencv-dev version: 2.3.1-7" with "synaptic". when I(my os is ubuntu 12.04 32bit)
.pro:
QT += core gui
TARGET = opencv_test1
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
main.cpp:
#include <QtGui/QApplication>
#include "widget.h"
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
//---------------------------------------------------------------
IplImage* img= cvLoadImage("/home/mrl-x200/Desktop/IR_0007.jpg");
//cvNamedWindow("hi",CV_WINDOW_AUTOSIZE);
//cvShowImage("hi",img);
//---------------------------------------------------------------
return a.exec();
}
when i ran it gave me this error:
error: undefined reference to `cvLoadImage'
error: collect2: ld returned 1 exit status
what am I should to do? thank you
either use the c++ api ( preferred ) , cv::Mat, cv::imread(), etc.
or include "opencv/cv.h" and "opencv/highgui.h"
honestly, don't use the old c-api, it has restricted functionality (can't access anything invented after 2010) and support for it will go away fast.
btw, which opencv version did you get via synaptic ? (current is 2.4.6)
thank you... libopencv-dev version: 2.3.1-7 . then I can't use any opencv2 functions?
oh, sure you can use opencv2 with 2.3.1.
cvLoadImage amd IplImage are from the old c-api, avoid those.
use cv::Mat img=cv::imread("my.png"), i.e, the c++ api
2.3.1 is a bit old, no face-recognition, stitching, hdr stuff. maybe update the one or other day
oh, and i did not read properly:
you need to link opencv_highgui231
thank you my friend :)
cvLoadImage should be fine as soon as you include library references in the .pro file, for example:
INCLUDEPATH += "C:/OpenCV245/mybuild2/install/include" LIBS += -L"C:/OpenCV245/mybuild2/install/lib" \ -lopencv_core245d \ -lopencv_imgproc245d \ -lopencv_highgui245d
DONT forget the 'l' letter just in front of each lib name.