c++ - 奇怪的编译错误 c++ opencv 2.4.10 在 ubuntu 14.04lts

标签 c++ opencv

基本上我的笔记本电脑上已经有了 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 库是否可以解决问题?

最佳答案

这些符号都来自 Qt,OpenCV 有一个可选的依赖项。您需要安装 Qt 或从 CMake 命令中删除 -D WITH_QT=ON。使用 Qt 进行构建将使您能够使用更好版本的 OpenCV 图形界面。

关于c++ - 奇怪的编译错误 c++ opencv 2.4.10 在 ubuntu 14.04lts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36207756/

相关文章:

c++ - 同时读取多个图像openCV

python - 如何在 python 中绘制低对比度对象的轮廓?

python-2.7 - 如何使用 Python 和 OpenCV 检测双眼瞳孔

c++ - 我必须在声明后清除 C++ vector 吗?

c++ - seekp 和 seekg 不适用于 fstream

c++ - bvector.h fatal error 没有这样的文件或目录

c++ - xcode (C++) 中的随机重复符号

c++ - 圆刚采集卡 C985 不适用于 C++ 和 openCV

c++ - 在 iOS 上使用 OpenCV 文件存储

c++ - 在 Visual Studio 中使用命令行参数进行调试