Results 1 to 12 of 12

Thread: error: undefined reference to `cvReleaseImage'

  1. #1
    Join Date
    Jul 2013
    Posts
    18
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Question error: undefined reference to `cvReleaseImage'

    I get the error in runtime

    Where am I wrong?

    .pro
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2013-09-11T03:55:37
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core
    8.  
    9. QT -= gui
    10.  
    11. TARGET = camera_onConsole
    12. CONFIG += console
    13. CONFIG -= app_bundle
    14.  
    15. TEMPLATE = app
    16.  
    17. INCLUDEPATH += D:\opencv\build\include
    18.  
    19. LIBS += -LD:\opencv\build\x86\mingw\lib
    20.  
    21. LIBS += -lopencv_highgui246 \
    22. -lopencv_imgproc246 \
    23. -lopencv_objdetect246
    24.  
    25. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    main.cpp
    Qt Code:
    1. #include <QCoreApplication>
    2. #include "opencv/cv.h"
    3. #include "opencv/highgui.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QCoreApplication a(argc, argv);
    8.  
    9. IplImage* img = cvLoadImage("D:/img.png");
    10. cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    11. cvShowImage("Example1", img);
    12. cvWaitKey(0);
    13. cvReleaseImage( &img );
    14. cvDestroyWindow( "Example1" );
    15. return a.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

    thanks for replies

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: error: undefined reference to `cvReleaseImage'

    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.

  3. #3
    Join Date
    Jul 2013
    Posts
    18
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: error: undefined reference to `cvReleaseImage'

    Qt Code:
    1. #include <QCoreApplication>
    2. #include "opencv/cv.h"
    3. #include "opencv/highgui.h"
    4. #include <opencv/cxcore.h>
    To copy to clipboard, switch view to plain text mode 

    I added cxcore.h but it shows me that error , is there anyone knows solution of this?

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: error: undefined reference to `cvReleaseImage'

    yes, link with the dll that contains it. That isn't the same as including a header.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Jul 2013
    Posts
    18
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: error: undefined reference to `cvReleaseImage'

    the folder includes dll files

    D:\opencv\build\x86\mingw\lib

    dll.png

    what's problem , I couldn't solve

    note: I'm using qt 5.1

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: error: undefined reference to `cvReleaseImage'

    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.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: error: undefined reference to `cvReleaseImage'

    Quote Originally Posted by ChrisW67 View Post
    it will not find a copy of Dickens (cvReleaseImage).
    "Great Expectations"?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: error: undefined reference to `cvReleaseImage'

    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

  9. #9
    Join Date
    Jul 2013
    Posts
    18
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: error: undefined reference to `cvReleaseImage'

    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 ?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: error: undefined reference to `cvReleaseImage'

    Try with Moby Dick
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: error: undefined reference to `cvReleaseImage'

    Quote Originally Posted by wysota View Post
    Try with Moby Dick
    rofl


    ten chars...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  12. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: error: undefined reference to `cvReleaseImage'

    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:
    1. Is the path to the image specified correctly?
    2. Does the image exist at the specified path?
    3. If it is a relative path is the working directory where you think it is?
    4. Is the image at that path a valid image?
    5. 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.
    Qt Code:
    1. IplImage* img = cvLoadImage("D:\\img.png");
    To copy to clipboard, switch view to plain text mode 

    "A Tale of Two Backslashes" perhaps?
    Last edited by ChrisW67; 17th September 2013 at 00:07.

Similar Threads

  1. undefined reference to vtable error
    By PaulDaviesC in forum Newbie
    Replies: 4
    Last Post: 20th April 2012, 16:11
  2. Replies: 5
    Last Post: 24th January 2011, 22:14
  3. Getting Undefined Reference Error
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2009, 02:12
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  5. Undefined Reference error!!!
    By Kapil in forum Newbie
    Replies: 25
    Last Post: 28th March 2006, 12:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.