Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error: undefined reference to `cvReleaseImage' (opencv + Qt)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
36 Posts 6 Posters 17.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RodMckay
    wrote on 15 Sept 2013, 13:30 last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 Sept 2013, 19:00 last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RodMckay
        wrote on 16 Sept 2013, 02:07 last edited by
        #3

        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)!

        1 Reply Last reply
        0
        • R Offline
          R Offline
          RodMckay
          wrote on 16 Sept 2013, 02:12 last edited by
          #4

          @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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 16 Sept 2013, 07:21 last edited by
            #5

            You are missing opencv_core

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • R Offline
              R Offline
              RodMckay
              wrote on 16 Sept 2013, 10:30 last edited by
              #6

              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

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 16 Sept 2013, 21:41 last edited by
                #7

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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RodMckay
                  wrote on 17 Sept 2013, 18:41 last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 17 Sept 2013, 20:56 last edited by
                    #9

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

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      RodMckay
                      wrote on 21 Sept 2013, 13:54 last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 21 Sept 2013, 19:54 last edited by
                        #11

                        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");@

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • Negar_mgN Offline
                          Negar_mgN Offline
                          Negar_mg
                          wrote on 27 Jun 2021, 10:11 last edited by
                          #12

                          Hi,
                          I followed this tutorial:
                          https://www.youtube.com/watch?v=ox6NFWE8xg4

                          this is my .pro file:

                          QT -= gui

                          CONFIG += c++11 console
                          CONFIG -= app_bundle

                          SOURCES +=
                          main.cpp

                          qnx: target.path = /tmp/$${TARGET}/bin
                          else: unix:!android: target.path = /opt/$${TARGET}/bin
                          !isEmpty(target.path): INSTALLS += target
                          INCLUDEPATH += C:\Qt\opencv_cv2\OPENCV1\include
                          LIBS += -LC:\Qt\opencv_cv2\OPENCV1\build-qt\lib
                          -lopencv_calib3d249d
                          -lopencv_contrib249d
                          -lopencv_core249d
                          -lopencv_features2d249d
                          -lopencv_flann249d
                          -lopencv_gpu249d
                          -lopencv_highgui249d
                          -lopencv_imgproc249d
                          -lopencv_legacy249d
                          -lopencv_ml249d
                          -lopencv_nonfree249d
                          -lopencv_objdetect249d
                          -lopencv_ocl249d
                          -lopencv_photo249d
                          -lopencv_stitching249d
                          -lopencv_superres249d
                          -lopencv_ts249d
                          -lopencv_video249d
                          -lopencv_videostab249d

                          this is my main file:

                          #include <iostream>

                          #include <opencv2/highgui/highgui.hpp>
                          #include <opencv2/imgproc/imgproc.hpp>
                          #include <opencv2/core/core.hpp>

                          using namespace cv;
                          using namespace std;

                          int main()
                          {
                          string imgloc="D:/ide/111.png";

                          Mat image = imread(imgloc);
                          

                          // Check for failure
                          if (image.empty())
                          {
                          cout << "Could not open or find the image" << endl;
                          return -1;
                          }

                          String windowName = "opencv"; //Name of the window
                          
                          namedWindow(windowName); // Create a window
                          
                          imshow(windowName, image); // Show our image inside the created window.
                          
                          waitKey(0); // Wait for any keystroke in the window
                          
                          
                          return 0;
                          

                          }

                          and this is my log output:

                          14:38:00: Running steps for project opencvtest10...
                          14:38:00: Starting: "C:\Qt\Qt5.12.11\5.12.11\mingw73_32\bin\qmake.exe" C:\Users\test\Documents\opencvtest10\opencvtest10.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
                          Info: creating stash file C:\Users\test\Documents\build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug.qmake.stash
                          14:38:04: The process "C:\Qt\Qt5.12.11\5.12.11\mingw73_32\bin\qmake.exe" exited normally.
                          14:38:04: Starting: "C:\Qt\Qt5.12.11\Tools\mingw730_32\bin\mingw32-make.exe" -f C:/Users/test/Documents/build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug/Makefile qmake_all
                          mingw32-make: Nothing to be done for 'qmake_all'.
                          14:38:05: The process "C:\Qt\Qt5.12.11\Tools\mingw730_32\bin\mingw32-make.exe" exited normally.
                          14:38:05: Starting: "C:\Qt\Qt5.12.11\Tools\mingw730_32\bin\mingw32-make.exe" -j4
                          C:/Qt/Qt5.12.11/Tools/mingw730_32/bin/mingw32-make -f Makefile.Debug
                          mingw32-make[1]: Entering directory 'C:/Users/test/Documents/build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug'
                          g++ -c -fno-keep-inline-dllexport -g -std=gnu++11 -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_CORE_LIB -I..\opencvtest10 -I. -I........\Qt\opencv_cv2\OPENCV1\include -I........\Qt\Qt5.12.11\5.12.11\mingw73_32\include -I........\Qt\Qt5.12.11\5.12.11\mingw73_32\include\QtCore -Idebug -I........\Qt\Qt5.12.11\5.12.11\mingw73_32\mkspecs\win32-g++ -o debug\main.o ..\opencvtest10\main.cpp
                          g++ -Wl,-subsystem,console -mthreads -o debug\opencvtest10.exe debug/main.o -LC:\Qt\opencv_cv2\OPENCV1\build-qt\lib -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_ocl249d -lopencv_photo249d -lopencv_stitching249d -lopencv_superres249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d C:\Qt\Qt5.12.11\5.12.11\mingw73_32\lib\libQt5Cored.a
                          debug/main.o: In function main': C:\Users\test\Documents\build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug/../opencvtest10/main.cpp:14: undefined reference to cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
                          C:\Users\test\Documents\build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug/../opencvtest10/main.cpp:25: undefined reference to cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' C:\Users\test\Documents\build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug/../opencvtest10/main.cpp:27: undefined reference to cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
                          collect2.exe: error: ld returned 1 exit status
                          mingw32-make[1]: *** [Makefile.Debug:65: debug/opencvtest10.exe] Error 1
                          mingw32-make: *** [Makefile:38: debug] Error 2
                          mingw32-make[1]: Leaving directory 'C:/Users/test/Documents/build-opencvtest10-Desktop_Qt_5_12_11_MinGW_32_bit-Debug'
                          14:38:13: The process "C:\Qt\Qt5.12.11\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
                          Error while building/deploying project opencvtest10 (kit: Desktop Qt 5.12.11 MinGW 32-bit)
                          When executing step "Make"
                          14:38:13: Elapsed time: 00:13.

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

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 27 Jun 2021, 11:13 last edited by
                            #13

                            Hi and welcome to devnet,

                            Do you have OpenCV built for the correct architecture ?
                            Is it built with MinGW ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            mrjjM 1 Reply Last reply 27 Jun 2021, 11:43
                            1
                            • S SGaist
                              27 Jun 2021, 11:13

                              Hi and welcome to devnet,

                              Do you have OpenCV built for the correct architecture ?
                              Is it built with MinGW ?

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 27 Jun 2021, 11:43 last edited by mrjj
                              #14

                              @SGaist

                              Hi
                              The video contains links to a Qt build version it seems. ( 3rd link in the text below)
                              But its for 5.4 ( and seems to contain virus/unclean ) so I could not check what
                              was actually inside.

                              and it seems the poster is using
                              Qt5.12.11 so I guess that is why it won't link.

                              @Negar_mg

                              I think you might have better luck with
                              https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
                              The other video is using something that is really old.

                              Unless it must be Qt 54. ofc. even if very, very old.

                              1 Reply Last reply
                              0
                              • Negar_mgN Offline
                                Negar_mgN Offline
                                Negar_mg
                                wrote on 27 Jun 2021, 13:32 last edited by Negar_mg
                                #15

                                i am using
                                Qt5.12.11 ,
                                OpenCV-2.4.9- Qt 5.4,
                                opencv-4.5.2-vc14_vc15
                                windows10

                                i did that link's steps but i have some errors in cmake.
                                this is logs:

                                {
                                sizeof(void) = 4 on 64 bit processor. Assume 32-bit compilation mode
                                Found PythonInterp: C:/Users/test/AppData/Local/Programs/Python/Python37/python.exe (found suitable version "3.7", minimum required is "2.7")
                                CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
                                CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:

                                PYTHON_EXECUTABLE=C:/Users/test/AppData/Local/Programs/Python/Python37/python.exe

                                PYTHON_VERSION_STRING=3.7

                                Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
                                or environment variables

                                Call Stack (most recent call first):
                                cmake/OpenCVDetectPython.cmake:271 (find_python)
                                CMakeLists.txt:614 (include)

                                Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
                                Reason given by package:
                                Interpreter: Wrong major version for the interpreter "C:/Users/test/AppData/Local/Programs/Python/Python37/python.exe"

                                }

                                {
                                Performing Test HAVE_CXX_WNO_ENUM_COMPARE_SWITCH - Failed
                                Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
                                VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
                                ADE: Download: v0.1.1f.zip
                                Try 1 failed
                                CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
                                ADE: Download failed: 35;"SSL connect error"

                                For details please refer to the download log file:

                                C:/Qt/opencv_cv2/opencv/release/CMakeDownloadLog.txt

                                Call Stack (most recent call first):
                                modules/gapi/cmake/DownloadADE.cmake:5 (ocv_download)
                                modules/gapi/cmake/init.cmake:19 (include)
                                cmake/OpenCVModule.cmake:298 (include)
                                cmake/OpenCVModule.cmake:361 (_add_modules_1)
                                modules/CMakeLists.txt:7 (ocv_glob_modules)

                                OpenCV Python: during development append to PYTHONPATH: C:/Qt/opencv_cv2/opencv/release/python_loader
                                Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
                                FFMPEG: Download: opencv_videoio_ffmpeg.dll
                                Try 1 failed
                                CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
                                FFMPEG: Download failed: 35;"SSL connect error"

                                For details please refer to the download log file:

                                C:/Qt/opencv_cv2/opencv/release/CMakeDownloadLog.txt

                                Call Stack (most recent call first):
                                3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
                                modules/videoio/cmake/detect_ffmpeg.cmake:14 (download_win_ffmpeg)
                                modules/videoio/cmake/init.cmake:7 (include)
                                modules/videoio/cmake/init.cmake:18 (add_backend)
                                cmake/OpenCVModule.cmake:298 (include)
                                cmake/OpenCVModule.cmake:361 (_add_modules_1)
                                modules/CMakeLists.txt:7 (ocv_glob_modules)

                                FFMPEG: Download: opencv_videoio_ffmpeg_64.dll
                                Try 1 failed
                                CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
                                FFMPEG: Download failed: 35;"SSL connect error"

                                For details please refer to the download log file:

                                C:/Qt/opencv_cv2/opencv/release/CMakeDownloadLog.txt

                                Call Stack (most recent call first):
                                3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
                                modules/videoio/cmake/detect_ffmpeg.cmake:14 (download_win_ffmpeg)
                                modules/videoio/cmake/init.cmake:7 (include)
                                modules/videoio/cmake/init.cmake:18 (add_backend)
                                cmake/OpenCVModule.cmake:298 (include)
                                cmake/OpenCVModule.cmake:361 (_add_modules_1)
                                modules/CMakeLists.txt:7 (ocv_glob_modules)

                                FFMPEG: Download: ffmpeg_version.cmake
                                Try 1 failed
                                CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
                                FFMPEG: Download failed: 35;"SSL connect error"

                                For details please refer to the download log file:

                                C:/Qt/opencv_cv2/opencv/release/CMakeDownloadLog.txt

                                Call Stack (most recent call first):
                                3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
                                modules/videoio/cmake/detect_ffmpeg.cmake:14 (download_win_ffmpeg)
                                modules/videoio/cmake/init.cmake:7 (include)
                                modules/videoio/cmake/init.cmake:18 (add_backend)
                                cmake/OpenCVModule.cmake:298 (include)
                                cmake/OpenCVModule.cmake:361 (_add_modules_1)
                                modules/CMakeLists.txt:7 (ocv_glob_modules)

                                }

                                {
                                Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD - Failed
                                CMake Warning at cmake/OpenCVGenSetupVars.cmake:54 (message):
                                CONFIGURATION IS NOT SUPPORTED: validate setupvars script in install
                                directory
                                Call Stack (most recent call first):
                                CMakeLists.txt:1010 (include)

                                }

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 27 Jun 2021, 21:51 last edited by
                                  #16

                                  What exactly are you trying to build ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • Negar_mgN Offline
                                    Negar_mgN Offline
                                    Negar_mg
                                    wrote on 28 Jun 2021, 04:02 last edited by
                                    #17

                                    I want to write a program to display an image or video from a webcam using Qt and Open CV.
                                    But I was not able to add Open CV to QT. When I used the following link, I encountered those errors in CMake.
                                    /................................................................................................
                                    https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
                                    /...............................................................................................
                                    And when I used the link from YouTube that I sent in the first comment, I encountered those errors in Qt.

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 28 Jun 2021, 21:17 last edited by
                                      #18

                                      From the looks of it, the OpenCV 4 you downloaded is built with Visual Studio, thus you have to use a Visual Studio build of Qt as well as mixing C++ compilers is not possible.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0
                                      • Negar_mgN Offline
                                        Negar_mgN Offline
                                        Negar_mg
                                        wrote on 29 Jun 2021, 03:56 last edited by
                                        #19

                                        You mean you think I can not use opencv with Qt?
                                        Is there no way?

                                        jsulmJ 1 Reply Last reply 29 Jun 2021, 04:14
                                        0
                                        • Negar_mgN Negar_mg
                                          29 Jun 2021, 03:56

                                          You mean you think I can not use opencv with Qt?
                                          Is there no way?

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on 29 Jun 2021, 04:14 last edited by
                                          #20

                                          @Negar_mg said in Error: undefined reference to &#x60;cvReleaseImage' (opencv + Qt):

                                          You mean you think I can not use opencv with Qt?

                                          No, that's not what @SGaist means.
                                          What he means is that you can't mix binaries built with different C++ compilers.
                                          And because OpenCV you downloaded was built using compiler from Microsoft Visual Studio you also need Qt built with this compiler. So, simply install MSVC2017 or MSVC2019 Qt.

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply
                                          2

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved