View Full Version : error: undefined reference to `cvReleaseImage'
studentQt
14th September 2013, 17:11
I get the error in runtime
Where am I wrong?
.pro
#-------------------------------------------------
#
# Project created by QtCreator 2013-09-11T03:55:37
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = camera_onConsole
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += D:\opencv\build\include
LIBS += -LD:\opencv\build\x86\mingw\lib
LIBS += -lopencv_highgui246 \
-lopencv_imgproc246 \
-lopencv_objdetect246
SOURCES += main.cpp
main.cpp
#include <QCoreApplication>
#include "opencv/cv.h"
#include "opencv/highgui.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
IplImage* img = cvLoadImage("D:/img.png");
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
return a.exec();
}
thanks for replies
ChrisW67
14th September 2013, 22:04
No, you get that error from your linker. This is before your program is able to run. The linker cannot find the symbol "cvReleaseImage" in any of the object and library files it has been told to look in.
As a guess I would say that cvReleaseImage exists in opencv_core.
studentQt
15th September 2013, 13:37
#include <QCoreApplication>
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <opencv/cxcore.h>
I added cxcore.h but it shows me that error , is there anyone knows solution of this?
amleto
15th September 2013, 15:06
yes, link with the dll that contains it. That isn't the same as including a header.
studentQt
16th September 2013, 02:59
the folder includes dll files
D:\opencv\build\x86\mingw\lib
9595
what's problem , I couldn't solve
note: I'm using qt 5.1
ChrisW67
16th September 2013, 04:17
The directory could contain a copy of every work in the British Library (library on your system) but if you tell the catalogue search (linker) to only look in the the Medieval collection (opencv_highgui library) it will not find a copy of Dickens (cvReleaseImage). The linker does not search every single library it finds on the library search path for performance and other reasons.
You tell the linker where to look for libraries with -L option, and the name of specific libraries to search for symbols with -l options in LIBS. You need another -l option. I have already told you my guess at the name of the library that contains the missing symbol.
wysota
16th September 2013, 06:33
it will not find a copy of Dickens (cvReleaseImage).
"Great Expectations"? :D
ChrisW67
16th September 2013, 08:36
Indeed... in which I play the part of Abel Magwitch, deported to New South Wales for forging bank notes and escaping custody, but ultimately making his fortune... still waiting for the last part ;)
studentQt
16th September 2013, 11:34
I add the -lopencv_core246 then it's solved but I have another problem . The program doesn't show the image and it ends with 'exited with code 0'
what should I do now ?
wysota
16th September 2013, 12:17
Try with Moby Dick :)
amleto
16th September 2013, 14:46
Try with Moby Dick :)
rofl
ten chars...
ChrisW67
16th September 2013, 23:58
I am sorry I started the literary theme now...
If the program is not showing an image then you need to ask yourself a few questions:
Is the path to the image specified correctly?
Does the image exist at the specified path?
If it is a relative path is the working directory where you think it is?
Is the image at that path a valid image?
Can OpenCV deal with images of that type?
You will note that none of the things have anything to do with Qt.
Assuming you have put the file in the root directory of D:, my money is on option 1: OpenCV is likely expecting a Windows-style path. Qt functions will generally accept either, but non-Qt functions will expect native path separators, i.e. backslashes properly escaped.
IplImage* img = cvLoadImage("D:\\img.png");
"A Tale of Two Backslashes" perhaps?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.