简体   繁体   English

ubuntu 14.04lts上奇怪的编译错误C ++ OpenCV 2.4.10

[英]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. 基本上,我已经通过anaconda python下载了我的笔记本电脑上的opencv 2.4.8。 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. 但是现在我需要C ++来编码计算机视觉模块,因此我尝试先安装opencv 2.4.11,但是在编译c ++程序时遇到编译错误。

The same error occurs when I deleted opencv 2.4.11 and installed opencv 2.4.10. 当我删除opencv 2.4.11并安装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. 我不确定opencv库还是其他软件依赖项是否有问题。 This is the cmake command which I used to build opencv 2.4.10. 这是我用来构建opencv 2.4.10的cmake命令。

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? 使用更高级别的程序(例如代码块)链接到opencv库是否可以解决问题?

These symbols are all from Qt, which OpenCV has an optional dependency on. 这些符号均来自Qt,OpenCV依赖于Qt。 You either need to install Qt or remove -D WITH_QT=ON from your CMake command. 您需要安装Qt或从CMake命令中删除-D WITH_QT=ON Building with Qt will let you use the nicer version of OpenCV's graphical interfaces. 使用Qt进行构建将使您可以使用OpenCV图形界面的更好版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM