Score:0

Linking error building OpenCV Contrib 4.5.4 with LibTiff4

af flag

Scenario

I am having some trouble building the latest version of OpenCV's contrib codebase from source, but the issue might just underlie a more generic lack of depth on my part:

Fetching the 4.5.4 tag from the official repos, I am using the build instructions in line with the official instructions for building OpenCV with its contrib codebase from here, whereas since currently the latest OpenCV requires libtiff version 4, I use the cmake flag mentioned therein for building libtiff version 4 itself as part of the OpenCV build ― so that the OpenCV build uses libtiff 4 and not the default Ubuntu 20.04 libtiff version 5 library and headers.

At a certain point in the OpenCV build nonetheless, it seems that one library is failing to find libtiff version 4 symbols, namely the library liblept:

/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'

I obtain the following output for this library ―

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

indeed I have libtiff5 installed:

$ apt list libtiff*
libtiff-dev/focal-updates,focal-security,now 4.1.0+git191117-2ubuntu0.20.04.2 amd64 
libtiff-dev/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 i386
libtiff-doc/focal-updates,focal-updates,focal-security,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 all
libtiff-opengl/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 amd64
libtiff-opengl/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 i386
libtiff-tools/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 amd64
libtiff-tools/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 i386
libtiff5-dev/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 amd64
libtiff5-dev/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 i386
libtiff5/focal-updates,focal-security,now 4.1.0+git191117-2ubuntu0.20.04.2 amd64 [installed]
libtiff5/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 i386
libtiffxx5/focal-updates,focal-security,now 4.1.0+git191117-2ubuntu0.20.04.2 amd64 [installed,automatic]
libtiffxx5/focal-updates,focal-security 4.1.0+git191117-2ubuntu0.20.04.2 i386

Looking here, I am just slightly puzzled by the table showing libtiff5's version requirement as 4.8.3.

Question

Does this mean that the build on my system is (as far as the ldd command may imply) attempting to link liblept5 against libtiff5, when trying to resolve those libtiff4 symbols? Or is it seeking to resolve them dynamically and thus failing to resolve as my system does not have libtiff4 globally available to the linker?

Further Version Information

  • Ubuntu 20.04
  • cmake 3.16.3
  • GNU Make 4.2.1
  • gcc 9.3.0
Score:0
af flag

This problem does not reproduce when using OpenCV 4.2.0 for Ubuntu 20.04. The problem from above does not occur there. You also often need to remember to use ―

sudo ldconfig

After installing libs, if you expect to build against them.

That said, I wonder if the final question clause of my question could be addressed, so as to promote a finer comprehension in such context as the one delineated in the question as asked.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.