Error: undefined reference to `cvReleaseImage' (opencv + Qt)



  • I try to write a simple image viewer program by using opencv int Qt5.1

    the problem is that Qt5.1 shows me 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 += -lopencv_highgui246
    -lopencv_imgproc246
    -lopencv_objdetect246

    SOURCES += main.cpp

    @

    .cpp
    @
    #include <QCoreApplication>
    #include "opencv/cv.h"
    #include "opencv/highgui.h"
    #include <opencv/cxcore.h>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    IplImage* img = cvLoadImage("D:/image.jpg");
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage("Example1", img);
    cvWaitKey(0);
    cvReleaseImage(&img);
    cvDestroyWindow( "Example1" );
    return a.exec&#40;&#41;;
    

    }

    @

    is there anyone who knows solution of this ? thanks for replies


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are not telling the build system where to find your opencv libraries
    You need to add something like:
    @
    LIBS += -LD:/opencv/build/lib/correct_architecture_folder
    @

    I would also advise to change all back slashes for forward slashes in your paths to avoid problems (Qt will translate them for you)

    Hope it helps



  • my fault , I forgot to add that here

    .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
    @

    maybe , this helps us to find a solution

    my dll files path : LIBS += -LD:\opencv\build\x86\mingw\lib

    and contents of the folder

    !http://www.qtcentre.org/attachment.php?attachmentid=9595&d=1379296529(contents of the dll folder)!



  • @INCLUDEPATH += D:/opencv/build/include

    LIBS += -LD:/opencv/build/x86/mingw/lib

    LIBS += -lopencv_highgui246
    -lopencv_imgproc246
    -lopencv_objdetect246@

    I wrote codes include slashe in this way but there is still the same error


  • Lifetime Qt Champion

    You are missing opencv_core



  • thank you very much . I run at the end :D

    there is another problem , I think it's my fault but I know where is that

    Application Output :
    excited with code 0

    and I couldn't see my image , do u have any suggestions?

    I try to change .jpg with .png but again I couldn't see the image

    thanks again


  • Lifetime Qt Champion

    Are you sure cvWaitKey(0) is the right value ?



  • yes, it's value is right, now I don't know what I can do for the program

    just I wanted to write a simple program to start opencv but I couldn't


  • Lifetime Qt Champion

    AFAIK, cvWaitKey(0) will wait for 0 ms so your application will show/hide your image too fast for you to see



  • thanks for your reply but it doesn't show again , I'm tired to try that


  • Lifetime Qt Champion

    Use cvWaitKey(-1) so it won't timeout, also you should check whether opencv needs windows style path e.g.

    @IplImage* img = cvLoadImage("D:\image.jpg");@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.