Kevin George
Kevin George

Reputation: 119

Weird compilation error c++ opencv 2.4.10 on ubuntu 14.04lts

Basically I already have opencv 2.4.8 on my laptop which I have downloaded through anaconda python. But now I need C++ to code a computer vision module, so I have tried installing opencv 2.4.11 first but I got compiling error when I compiled the c++ program.

The same error occurs when I deleted opencv 2.4.11 and installed opencv 2.4.10. Below is just the last part of the huge error that I get.

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x1e0): undefined reference to `QGraphicsView::drawItems(QPainter*, int, QGraphicsItem**, QStyleOptionGraphicsItem const*)'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x268): undefined reference to `non-virtual thunk to QWidget::devType() const'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x270): undefined reference to `non-virtual thunk to QWidget::paintEngine() const'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x278): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x280): undefined reference to `non-virtual thunk to QWidget::initPainter(QPainter*) const'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x288): undefined reference to `non-virtual thunk to QWidget::redirected(QPoint*) const'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro._ZTV15DefaultViewPort[_ZTV15DefaultViewPort]+0x290): undefined reference to `non-virtual thunk to QWidget::sharedPainter() const'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x0): undefined reference to `QGraphicsView::staticMetaObject'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x40): undefined reference to `QWidget::staticMetaObject'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x80): undefined reference to `QWidget::staticMetaObject'

 /usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0xc0): undefined reference to `QHBoxLayout::staticMetaObject'

     /usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x100): undefined reference to `QRadioButton::staticMetaObject'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x140): undefined reference to `QCheckBox::staticMetaObject'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x180): undefined reference to `QPushButton::staticMetaObject'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x1c0): undefined reference to `QHBoxLayout::staticMetaObject'

/usr/local/lib/libopencv_highgui.a(opencv_highgui_automoc.cpp.o):(.data.rel.ro+0x200): undefined reference to `QObject::staticMetaObject'

collect2: error: ld returned 1 exit status

I am not sure whether it is a problem with the opencv libraries or some other software dependencies. This is the cmake command which I used to build opencv 2.4.10.

cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_FAT_JAVA_LIB=ON -D INSTALL_TO_MANGLED_PATHS=ON -D INSTALL_CREATE_DISTRIB=ON -D INSTALL_TESTS=ON -D ENABLE_FAST_MATH=ON -D WITH_IMAGEIO=ON -D BUILD_SHARED_LIBS=OFF -D WITH_GSTREAMER=ON -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so -D WITH_FFMPEG=OFF ..

I can't find any solution to this problem. Would using a higher level program like codeblocks to link to opencv libraries solve the problem?

Upvotes: 0

Views: 497

Answers (1)

Francesca Nannizzi
Francesca Nannizzi

Reputation: 1705

These symbols are all from Qt, which OpenCV has an optional dependency on. You either need to install Qt or remove -D WITH_QT=ON from your CMake command. Building with Qt will let you use the nicer version of OpenCV's graphical interfaces.

Upvotes: 2

Related Questions