Reputation: 169
i'm trying to compiling a first open cv program with qt5 , but when i try to compile i have this strange error
Starting /home/QtContour/build-untitled-Desktop_Qt_5_0_2_GCC_64bit-Debug/untitled...
*** Error in `/home/QtContour/build-untitled-Desktop_Qt_5_0_2_GCC_64bit-Debug/untitled': realloc(): invalid pointer: 0x00007f64e3750340 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7f576)[0x7f64e26b0576]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x300)[0x7f64e26b4da0]
/home//Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QListData7reallocEi+0x26)[0x7f64e31e3e46]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QListData7prependEv+0x82)[0x7f64e31e4012]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN10QTextCodecC1Ev+0x85)[0x7f64e339dbe5]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x2728b9)[0x7f64e33a18b9]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x272d0d)[0x7f64e33a1d0d]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN10QTextCodec14codecForLocaleEv+0x32)[0x7f64e339d592]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZNK7QString11toLocal8BitEv+0x19)[0x7f64e3211bd9]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x80702)[0x7f64e31af702]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x7e07c)[0x7f64e31ad07c]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x7e19a)[0x7f64e31ad19a]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZNK14QMessageLogger5fatalEPKcz+0xa9)[0x7f64e31ad8c9]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QMetaType22registerNormalizedTypeERK10QByteArrayPFvPvEPFS3_PKvES5_PFS3_S3_S7_Ei6QFlagsINS_8TypeFlagEEPK11QMetaObject+0x48a)[0x7f64e3361bba]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QMetaType12registerTypeEPKcPFvPvEPFS2_PKvES4_PFS2_S2_S6_Ei6QFlagsINS_8TypeFlagEEPK11QMetaObject+0x61)[0x7f64e3361c51]
/home/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QMetaType12registerTypeEPKcPFvPvEPFS2_PKvE+0x2a)[0x7f64e3361cea]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x1b995e)[0x7f64ddf0e95e]
/lib64/ld-linux-x86-64.so.2(+0xf876)[0x7f64e4679876]
/lib64/ld-linux-x86-64.so.2(+0xf930)[0x7f64e4679930]
/lib64/ld-linux-x86-64.so.2(+0x168a)[0x7f64e466b68a]
======= Memory map: ========
00400000-00405000 r-xp 00000000 08:01 7604445 /home/QtContour/build-untitled-Desktop_Qt_5_0_2_GCC_64bit-Debug/untitled
00604000-00605000 r--p 00004000 08:01 7604445 /home/QtContour/build-untitled-Desktop_Qt_5_0_2_GCC_64bit-Debug/untitled
00605000-00606000 rw-p 00005000 08:01 7604445 /home/QtContour/build-untitled-Desktop_Qt_5_0_2_GCC_64bit-Debug/untitled
01890000-018b1000 rw-p 00000000 00:00 0 [heap]
7f64d40a5000-7f64d40a8000 r-xp 00000000 08:01 42208894 /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7f64d40a8000-7f64d42a7000 ---p 00003000 08:01 42208894 /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7f64d42a7000-7f64d42a8000 r--p 00002000 08:01 42208894 /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7f64d42a8000-7f64d42a9000 rw-p 00003000 08:01 42208894 /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7f64d42a9000-7f64d42ad000 r-xp 00000000 08:01 42209011 /lib/x86_64-linux-gnu/libuuid.so.1.3.0 ... ....(much more)
my main.cpp is that
#include "mainwindow.h"
#include <QApplication>
#include <opencv/cv.h>
//#include <opencv2/highgui/highgui.hpp>
#include"highgui.h"
using namespace cv;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
Mat frame;
VideoCapture cap(0);
if(cap.isOpened()){
// check if we succeeded
namedWindow("normal",1);
for(;;)
{
cap >> frame; // get a new frame from camera
imshow("nomral",frame);
if(waitKey(30) >= 0) break;
}
}
return a.exec();
}
and my project propieties are
#-------------------------------------------------
#
# Project created by QtCreator 2013-07-02T09:42:06
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
unix: CONFIG += link_pkgconfig
unix: PKGCONFIG += opencv
i don't know who caused this problem , it's first time i see it in my life i hope you can help me
thanks anyway
Upvotes: 2
Views: 1988
Reputation: 658
I have met the same problem, I search it the whole morning and solve it by re-install the OpenCV. My opencv was the version 2.4.9, and build on the Ubuntu 12.04 system , I installed the QT creator later using the Linux installer. The version of QT creator is 3.1.2 based on the QT 5.3.1. My OpenCV was installed on a customized path. I just deleted the build folder
cd opencv-2.4.9
rm -r build
and I just build the OpenCV again without the -D WITH_QT flag in cmake
mkdir build
cd build
cmake -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON ..
make -j4
sudo make install
the -j4 flag in the make means that make in 4 cores parallel. and the Magic happens, the code works! the reason why it does not work is that when using the cmake WITH_QT flag the system build the opencv using the system default version of the qt, which is not compatible with the newest version of the qt downloaded from the website. however, to make it work, we must have the right version of the QT. And from my experience, we do not have to unckeck the WITH_TBB.
Upvotes: 1
Reputation: 550
when using cmake, be sure to uncheck WITH_QT. The internal version(Qt4.0) used in Opencv might cause conflicts with QT Creator(Qt 5.0) That's how I solved my problem.
just clear the cmake cache, uncheck WITH_QT (and maybe WITH_TBB also), then make sure the previous opencv build is removed, then rebuild opencv. Boom, now it works!
Upvotes: 2