ubuntu 14.04lts 上的奇怪编译错误 c++ opencv 2.4.10
Posted
技术标签:
【中文标题】ubuntu 14.04lts 上的奇怪编译错误 c++ opencv 2.4.10【英文标题】:Weird compilation error c++ opencv 2.4.10 on ubuntu 14.04lts 【发布时间】:2016-03-24 18:43:37 【问题描述】:基本上,我的笔记本电脑上已经有 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 库会解决问题吗?
【问题讨论】:
【参考方案1】:这些符号都来自 Qt,OpenCV 有一个可选的依赖项。您需要安装 Qt 或从 CMake 命令中删除 -D WITH_QT=ON
。使用 Qt 构建可以让您使用更好的 OpenCV 图形界面版本。
【讨论】:
非常感谢您,我刚刚重新安装并删除了 -D WITH_QT=ON 选项。再次感谢您的帮助。我是 *** 的新手,所以我想知道我能如何帮助你,是否足够支持答案? 嗨@kevyam,很高兴这对您有所帮助。最好的办法是“接受”答案,这既清楚地表明了这个问题得到了回答,也给了我一些观点:)以上是关于ubuntu 14.04lts 上的奇怪编译错误 c++ opencv 2.4.10的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Ubuntu 14.04 LTS 中安装 ia32-libs (Trusty Tahr)
64位的ubuntu14.04 LTS安装 Linux交叉编译工具链及32位“ia32-libs”依赖库
phpMyAdmin - 错误 |缺少 mbstring 扩展名。请检查您在 Ubuntu 14.04 LTS 中的 PHP 配置