Ask Your Question
0

qt and imread -> realloc(): invalid old size: 0x0000000000611a20

asked 2013-10-19 17:19:21 -0600

Pete gravatar image

Hi,

I am using Qt 4.8.4 and opencv-2.4.6.1 and get an odd error when running the application.

The offending line in the code is

        Mat img1 = imread(name, CV_LOAD_IMAGE_GRAYSCALE);

When I compile a simple test program without Qt libraries then OpenCV works just fine and loads the image. However when built with the Qt libraries the build works just fine but when the program is run I get

$ ./opencvnqt
*** Error in `./opencvnqt': realloc(): invalid old size: 0x00000000006119e0 ***

Does anyone know why this run time error is occuring and how to avoid it or how to debug it? FYI the build and link lines look like this:

g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DVERSION=1.0 -DPD_NOT_SERIAL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I../OpenCVNQt -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/local/include/opencv -I. -I. -I../OpenCVNQt -I. -o MainWindow.o MainWindow.cpp

g++ -m64 -o opencvnqt main.o MainWindow.o moc_MainWindow.o  -L/usr/lib/x86_64-linux-gnu -L /usr/local/lib -lopencv_core -lopencv_highgui -lQtGui -lQtCore -lpthread
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-10-22 16:21:39 -0600

Pete gravatar image

This problem was caused on Ubuntu 13.04 where qtcreator does not detect the qt5 installation. When I built OpenCV the OpenCV build correctly picked up the qt5 installation. When I started the Qt project (in my case OpenCVNQt) with qtcreator only qmake-qt4 was detected. So the problem I saw was a result of a mismatch between Qt5 libraries used in OpenCV and Qt4 libraries used in my project. To fix this I had to delete the Qt project OpenCVNQt.pro.user file and manual add /usr/lib/x86_64-linux-gnu/qt5/bin/qmake ({Tools->Options; Build & Run; Qt Versions} See http://askubuntu.com/questions/279421/how-can-i-install-qt-5-x-on-12-04-lts). Also you have to manual add the Qt5 Kit ({Tools->Options; Build & Run; Kits}). Then I updated the project code, in particular I had to add QT += widgets to the OpenCVNQt.pro file and change #include <qtgui> to #include <qtwidgets> (see http://qt-project.org/doc/qt-5.0/qtdoc/portingguide.html).

Now it works!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-19 17:19:21 -0600

Seen: 970 times

Last updated: Oct 22 '13