基本上我已经在笔记本电脑上安装了opencv 2.4.8,我已经通过anaconda python下载了。但是现在我需要C ++来编写一个计算机视觉模块,所以我先尝试安装opencv 2.4.11但是在编译c ++程序时遇到了编译错误。
删除opencv 2.4.11并安装opencv 2.4.10时发生同样的错误。下面是我得到的巨大错误的最后一部分。
/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
我不确定opencv库或其他软件依赖项是否存在问题。 这是我用来构建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 ..
我无法找到解决此问题的方法。使用像代码块这样的更高级别的程序来链接到opencv库会解决问题吗?
答案 0 :(得分:2)
这些符号都来自Qt,OpenCV具有可选的依赖性。您需要安装Qt或从CMake命令中删除-D WITH_QT=ON
。使用Qt构建将允许您使用更好的OpenCV图形界面版本。