Skip to content

Building OpenCV Contrib 4.5.4 from source along with LibTiff4 #3114

Open
@matanox

Description

@matanox

System information (version)

  • Building OpenCV 4.5.4 and OpenCV Contrib 4.5.4 from source
  • Ubuntu 20.04
  • cmake 3.16.3
  • GNU Make 4.2.1
  • gcc 9.3.0

Build failure description

I am using BUILD_TIFF=ON as on my (Ubuntu 20.04) system the globally installed libtiff is version 5 not 4, so this allows building OpenCV without downgrading from the distro default version of LibTiff. This has indeed avoided linking errors when building OpenCV without contrib in my case. However, building along with OpenCV using the -DBUILD_TIFF flag set to on, seems to still bump into linkage errors relating to LibTiff version 4:

$ cmake -DWITH_OPENEXR=OFF -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/ -DBUILD_TIFF=ON ../opencv

Linking CXX executable ../../bin/opencv_test_text
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFGetFieldDefaulted@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFCleanup@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFIsTiled@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFReadRGBAImageOriented@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFOpen@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFSetSubDirectory@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFSetField@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFCurrentDirOffset@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFPrintDirectory@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFGetField@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFSetDirectory@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFReadScanline@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFClose@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFClientOpen@LIBTIFF_4.0'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/liblept.so.5: undefined reference to `TIFFGetVersion@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status

If my hunch after a few hours' battle with linking OpenCV with Contrib is correct, I just wonder whether contrib builds against the LibTiff that gets dynamically built as part of the OpenCV build courtesy of that flag.

That said to be honest, I'm a bit confused seeing the following libtiff linking information for the offending library:

$ ldd /usr/lib/x86_64-linux-gnu/liblept.so.5
.
.
.
lbtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007fbd367bb000)

Steps to reproduce

  • make sure libtiff version 4 is not installed globally (to reproduce the Ubuntu 20.04 default situation)
  • fetch OpenCV 4.5.4 and OpenCV Contrib 4.5.4 from Github
  • follow the official build instructions, only with BUILD_TIFF=ON so as to enable the build without relying on a globally installed libtiff version 4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions