【问题标题】:Error installing OpenCV on Ubuntu 16.04在 Ubuntu 16.04 上安装 OpenCV 时出错
【发布时间】:2016-12-08 08:52:53
【问题描述】:

我一直在尝试在 Ubuntu 16.04 上安装 OpenCV,但没有使用几个教程,但我总是遇到错误。这是我遵循本教程的最后一篇:

https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-OpenCV-3.1-Installation-Guide

我能做什么?

[ 48%] Linking CXX executable ../../bin/opencv_test_viz
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFIsTiled@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadTile@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `_TIFFfree@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFGetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFTileSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFClientOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFGetFieldDefaulted@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFNumberOfDirectories@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadRGBAImage@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `_TIFFmalloc@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFNumberOfTiles@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
modules/viz/CMakeFiles/opencv_test_viz.dir/build.make:236: recipe for target 'bin/opencv_test_viz' failed
make[2]: *** [bin/opencv_test_viz] Error 1
CMakeFiles/Makefile2:3306: recipe for target 'modules/viz/CMakeFiles/opencv_test_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/opencv_test_viz.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

【问题讨论】:

  • Tagged Image File Format (TIFF) 的库似乎不见了。您需要安装或验证是否安装了libtiff5-dev。如果libtiff5-dev 不包含该库,您还需要安装libtiff5
  • 您可能想试试the install-opencv.sh script。它说它已经针对 Ubuntu 16.04 进行了测试,如果您查看内部,您可以看到它正在安装的软件包(例如 libpng-dev 和 libtiff5-dev)。

标签: opencv ubuntu-16.04 opencv3.1


【解决方案1】:

我按照相同的教程安装 opencv 并且遇到了同样的问题。 这对我有用:

sudo apt-get autoremove libtiff5-dev

sudo apt-get install libtiff5-dev

进入opencv目录。

cd build/(估计已经创建了,否则创建)

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

make

然后继续本教程。

【讨论】:

  • sudo apt-get autoremove libtiff5-dev 警告!不要这样做 - 它会删除数百个包
  • 这导致的问题多于解决的问题!正如@Nulldevice 所指出的,数百个包被删除,你最终会得到一个损坏的系统。特别是,所有的 ROS 包都被删除了。用户 gevang 的回答比较明智。
【解决方案2】:

根据this,OpenCV需要libtiff4,Ubuntu已经放弃了,即替换它的包是libtiff5-dev

作为一种临时解决方法,您可以在配置时在 cmake 上指定 -DBUILD_TIFF=ON,以便构建随 OpenCV 分发的 libtiff4 版本。

这在 Ubuntu 16.04 和 OpenCV 3.2.1 中对我有用。

【讨论】:

  • 这似乎对我在 ubuntu 16.04 上的 opencv 3.4.3 上工作,虽然它应该是 -D BUILD_TIFF=ON,对吧? (缺少空格)
  • 这个答案在 Ubuntu 18.04 上适用于我,而无论出于何种原因接受的答案都不起作用。谢谢!
  • 我现在在较新的 Ubuntu 版本上将此解决方法用于 OpenCV 4.5。在我的用例中看不到让 OpenCV 自带这个库的自己版本的缺点。
【解决方案3】:

看起来您需要安装/重新安装 libpng。

【讨论】:

  • 我已经更新了我得到的错误。你能再检查一下吗。我认为这与我正在使用 libtiff5-dev 并且似乎期待 libtiff4-dev 的事实有关
【解决方案4】:

尝试make clean,然后再次执行make命令。通常,如果您尝试 make 命令而不清理之前的安装,则在一次失败后,您会收到错误。

【讨论】:

    【解决方案5】:

    我有类似的问题。我正在构建 openCV 3.3.0opencv_contrib 存储库。事实证明,将标志 -D BUILD_TIFF=ON 包含在 cmake 命令中已经解决了 gevang 指出的问题。

    Ps.:由于我只承认 gevang 提供的解决方案,这应该是评论而不是答案,但我缺少相应的权利。对此感到抱歉。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多