Error: undefined reference to `cvReleaseImage' (opencv + Qt)
-
@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. -
If I understand correctly, there are 2 ways to solve this issue:
1- use vc compiler in qt to compile my codes.
Here is a link I found for that, please let me know if it is correct:
https://stackoverflow.com/questions/47773289/debugging-in-qtcreator-using-msvc2017-compiler
2- download and compile opencv using qt compiler, and then refering to that folder in my qt.
Is this compiler called minWG?
Please give me a link or instruction on how to do that. -
If I understand correctly, there are 2 ways to solve this issue:
1- use vc compiler in qt to compile my codes.
Here is a link I found for that, please let me know if it is correct:
https://stackoverflow.com/questions/47773289/debugging-in-qtcreator-using-msvc2017-compiler
2- download and compile opencv using qt compiler, and then refering to that folder in my qt.
Is this compiler called minWG?
Please give me a link or instruction on how to do that.@Negar_mg said in Error: undefined reference to `cvReleaseImage' (opencv + Qt):
Is this compiler called minWG?
I don't know what compiler you are using. This is something you should know.
To use Visual Studio compiler you first need to install Visual Studio together with C++ tools. You can use the free Community edition. Then install Qt for that Visual Studio version. Then you should have a Kit in QtCreator configured to use Visual Studio compiler. The link you posted looks legit, just download more recent Qt version.
-
I do not need vs and i have uninstalled it
But i still get the error mentioned above
How can i install opencv on qt without visual studio?@Negar_mg Build OpenCV using the compiler you're using with Qt...
@mrjj Already gave you a link: https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
Also there is official OpenCV documentation for that: https://docs.opencv.org/3.4/d3/d52/tutorial_windows_install.html -
I have followed the steps in the link you provided, but cmake step raised some errors. Its log is bellow:
Log:
{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)
} -
Hi
Could you try with python 2.7 instead?It seems to complain about the 3.7 version
CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:
Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
Wrong major version for the interpreter "C:/Users/test/AppData/Local/Programs/Python/Python37/python.exe" -
I installed Python 2.7, checked that it was installed with the python -v command in cmd, then according to this link
//...........................................................................................
https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
//...........................................................................................
In cmake, I selected the source and destination, but after clicking the configure button, I encountered these errors:
//...........................................................................................
{
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)}
-
@Negar_mg I don't know how. This is an OpenCV issue and has nothing to do with Qt. Please ask in an OpenCV forum.
You should at least consider doing what the error output suggests:
"For details please refer to the download log file:C:/Qt/opencv_cv2/opencv/Release/CMakeDownloadLog.txt"
It looks like it can't download some dependencies. -
Yes. I know that it cannot download a link, but i have no idea how to fix it. Could you please give me a hint
«Error»
{
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)}
-
Yes. I know that it cannot download a link, but i have no idea how to fix it. Could you please give me a hint
«Error»
{
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)}
-
@RodMckay said in 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();}
@
is there anyone who knows solution of this ? thanks for repliesThe error in the runtime could be due to various reasons, and it would be helpful if you could provide more information about the specific error message or behavior that you are encountering.
However, based on the code that you have provided, there are a few issues that might be causing the problem:
The Qt project file (.pro) is missing the inclusion of the "widgets" module, which is required for creating GUI applications. You can add it by modifying the "QT" line in your .pro file to:
QT += core widgets
The OpenCV library that you are linking to is version 2.4.6, which might not be compatible with the version of Qt that you are using (Qt 5.1). You could try linking to a more recent version of OpenCV (e.g., 4.x), or using an older version of Qt that is compatible with OpenCV 2.4.6.
The use of the "IplImage" data type is deprecated in newer versions of OpenCV, and you might encounter compatibility issues when using it with Qt. You could try using the newer "cv::Mat" data type instead, which is recommended for working with images in OpenCV.
Here is a modified version of your code that addresses these issues:
.pro
@
#-------------------------------------------------Project created by QtCreator 2013-09-11T03:55:37
#-------------------------------------------------QT += core widgets
TARGET = camera_onConsole
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
INCLUDEPATH += D:\opencv\build\include
LIBS += -lopencv_highgui
-lopencv_imgproc
-lopencv_objdetectSOURCES += main.cpp
@
.cpp
@
#include <QCoreApplication>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);cv::Mat img = cv::imread("D:/image.jpg"); cv::namedWindow("Example1", cv::WINDOW_AUTOSIZE); cv::imshow("Example1", img); cv::waitKey(0); cv::destroyWindow("Example1"); return a.exec();
}
@
Note that this code uses the newer "cv::Mat" data type instead of "IplImage", and also uses the updated function names for creating and destroying windows in OpenCV.
-
S SGaist moved this topic from Qt in Education on