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_bundleTEMPLATE = app
INCLUDEPATH += D:\opencv\build\include
LIBS += -lopencv_highgui246
-lopencv_imgproc246
-lopencv_objdetect246SOURCES += 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();
}
@
is there anyone who knows solution of this ? thanks for replies
-
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_bundleTEMPLATE = app
INCLUDEPATH += D:\opencv\build\include
LIBS += -LD:\opencv\build\x86\mingw\lib
LIBS += -lopencv_highgui246
-lopencv_imgproc246
-lopencv_objdetect246SOURCES += 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)!
-
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 0and 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
-
Are you sure cvWaitKey(0) is the right value ?
-
AFAIK, cvWaitKey(0) will wait for 0 ms so your application will show/hide your image too fast for you to see
-
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");@
-
Hi,
I followed this tutorial:
https://www.youtube.com/watch?v=ox6NFWE8xg4this is my .pro file:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundleSOURCES +=
main.cppqnx: 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_videostab249dthis 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 functionmain': 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 tocv::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
-
Hi and welcome to devnet,
Do you have OpenCV built for the correct architecture ?
Is it built with MinGW ? -
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.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.
-
i am using
Qt5.12.11 ,
OpenCV-2.4.9- Qt 5.4,
opencv-4.5.2-vc14_vc15
windows10i 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 variablesCall 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)}
-
What exactly are you trying to build ?
-
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. -
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.
-
@Negar_mg said in Error: undefined reference to `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.