15

I have being trying to install OpenCV on Ubuntu 16.04 unsing several tutorials and i always end up with an error. This is the last one i've got following this tutorial:

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

What can i do?

[ 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
Rafael Reis
  • 600
  • 2
  • 6
  • 19
  • The library for `Tagged Image File Format` (`TIFF`) seems to be missing. You need to install or verify that `libtiff5-dev` is installed. If `libtiff5-dev` doesn't contain the library, you will also need to install `libtiff5`. – alvits Aug 02 '16 at 23:12
  • You might want to try [the install-opencv.sh script](http://milq.github.io/install-opencv-ubuntu-debian/). It says its been tested for Ubuntu 16.04 and if you look inside you can see the packages (such as libpng-dev and libtiff5-dev) that it is installing. – unutbu Aug 03 '16 at 00:37

5 Answers5

13

I followed the same tutorial for install opencv and I had the same problem. This works for me:

sudo apt-get autoremove libtiff5-dev

sudo apt-get install libtiff5-dev

Enter the opencv directory.

cd build/ (I guess that is already created,otherwise create it)

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

then continue with the tutorial.

gevang
  • 4,994
  • 25
  • 33
Jose Jaita
  • 170
  • 2
  • 3
    sudo apt-get autoremove libtiff5-dev Warning! Do not do this - it will remove hundreds of packages – Nulldevice Dec 05 '18 at 04:37
  • This causes more problems than it solves! As pointed by @Nulldevice hundreds of packages get removed and you end up with a broken system. Especially, all ROS packages are done away. The answer by user gevang is more sensible. – vyi Aug 22 '21 at 16:09
12

According to this, OpenCV needs libtiff4, which Ubuntu has dropped, i.e. the package that replaced it is libtiff5-dev.

As a temporary workaround you can specify -DBUILD_TIFF=ON on cmake when configuring, in order to build the libtiff4 version that is distributed with OpenCV.

This worked for me in Ubuntu 16.04, with OpenCV 3.2.1.

gevang
  • 4,994
  • 25
  • 33
  • This seems to work for me on opencv 3.4.3 on ubuntu 16.04, although it should be `-D BUILD_TIFF=ON`, right? (missing whitespace) – RTbecard Nov 03 '18 at 14:07
  • This answer works for me on Ubuntu 18.04, and the accepted answer for whatever reason does not. Thanks! – yuqli Sep 11 '19 at 22:41
  • I used this workaround for OpenCV 4.5 on a newer Ubuntu version now. Can't see the drawback of having OpenCV bring its own version of this lib in my use case. – matanster Nov 20 '21 at 19:12
1

Looks like you need to install/reinstall libpng.

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • 1
    I have updeted the error i am geting. Can you plz check it again. I think it has something to do with the fact that i am using libtiff5-dev and it seems to be expecting libtiff4-dev – Rafael Reis Aug 02 '16 at 23:11
1

Try make clean ,and then again execute the make command. Generally after one failure if you try the make command without cleaning the earlier installation, you get errors.

Jayanth Reddy
  • 347
  • 1
  • 3
  • 7
0

I had similar issue. I was building openCV 3.3.0 together with opencv_contrib repository. It turned out that including the flag -D BUILD_TIFF=ON with cmake command resolved the issue as pointed out by gevang already.

Ps.: Since I'm only acknowledging the solution provided by gevang, this should rather a be comment instead of an answer, but I'm missing the corresponding rights. Sorry for that.

Matej Jeglič
  • 403
  • 3
  • 11