Linking error with `libopencv_highgui.so` under Ubuntu 14.04, strange result with `libtiff.so.5`
Asked Answered
M

5

12

Problem

I'm compiling the deep learning library Caffe in Ubuntu 14.04(64 bit).

OpenCV(Version: 2.4.8+dfsg1-2ubuntu1) is installed from ubuntu packages server with :

sudo apt-get install libopencv-dev

Compile Caffe with CMake 2.8.

Linking error:

Linking CXX executable caffe-

/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.8: undefined reference to `TIFFOpen@LIBTIFF_4.0'

Infomation

It seems some symbols of TIFF library were not found. I made some effort to find the reason(without luck). Here's some infomation about the libraries.

TIFF library linked by libopencv_highgui.so.2.4.8

$ ldd libopencv_highgui.so.2.4.8 | grep tiff

libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f978313b000)

Import symbols of libopencv_highgui.so.2.4.8

$ readelf -s libopencv_highgui.so.2.4.8 |grep TIFFOpen

62: 0000000000000000 0 FUNC GLOBAL DEFAULT UND TIFFOpen@LIBTIFF_4.0 (9)

Note: There is one single @ in the symbol names.

$ nm -D libopencv_highgui.so.2.4.8| grep TIFFOpen

U TIFFOpen

Export symbols of libtiff.so.5:

$ nm -D /usr/lib/x86_64-linux-gnu/libtiff.so.5

0000000000000000 A LIBTIFF_4.0

...

00000000000429f0 T TIFFOpen

...

$ readelf -s /usr/lib/x86_64-linux-gnu/libtiff.so.5|grep TIFFOpen

99: 00000000000429f0 239 FUNC GLOBAL DEFAULT 12 TIFFOpen@@LIBTIFF_4.0

Note: There are two @(@@) in the symbol names.

My confusion

  1. Is it because libtiff.so.5 has @@ in the symbol names instead of @ that made the linking error

    libopencv_highgui.so.2.4.8: undefined reference to 'TIFFIsTiled@LIBTIFF_4.0'

  2. What's the difference between @ and @@ in symbol names?
  3. What's the meaning of the suffix LIBTIFF_4.0 of symbols names in libtiff.so.5?
  4. Many people said it's because OpenCV need libtiff4-dev which is not provided by Ubuntu 14.04. Then why the Ubuntu guys put a broken package on the package server.
  5. How to solve the linking problem?

I'm not a profession on compiling and linking. Sorry for such a long post. Just what to provide enough infomation for you guys to help me. Appreciate for any suggestions.

P.S. If you need more infomation of those libs, feel free to say in the comment.

Magnetics answered 26/3, 2015 at 6:44 Comment(4)
Too long, can you make your post concise?Gaikwar
Now it's more concise. @GolazoMagnetics
Did you end up solving this problem? If so, could you please describe the solution. Thanks!Mandelbaum
Maybe libopencv-dev package was not build with TIFF library, anyway your can build OpenCV from source.Verina
D
3

Old question but still without an answer so here it goes (I came across the same error today):

  1. That is not why the linker fails. If it was able to find libtiff.so.5 it would have linked just fine.

  2. @ vs @@ is just a way to track difference versions of the function. More details here https://sourceware.org/binutils/docs/ld/VERSION.html

  3. LIBTIFF_4.0 means it is that specific version of TIFFOpen that is required when dynamically loading the symbol.

  4. That is probably a good way to fix the issue. It's likely that without the libtiff-dev package the libtiff.so symbolic linked file doesn't exit in /usr/lib/x86_64-linux-gnu/ so the linker will not be able to find the library (it knows nothing about libtiff.so.5 unless you tell it explicitly).

  5. a. You may be able to test 4. by invoking the linker command line yourself from the command line. If you compiled caffe with cmake you'll find the linker command under tools/CMakeFiles/caffe.bin.dir/link.txt. Just add /usr/lib/x86_64-linux-gnu/libtiff.so.5 to the command line and it should work.

    b. Alternatively manually create the symbolic link /usr/lib/x86_64-linux-gnu/libtiff.so

    c. install the dev package, which should do that for you. Also make sure that cmake knows about /usr/lib/x86_64-linux-gnu/ by specify extra library path

    d. check that there are no other libtiff.so library lurking in your system if previous steps don't work (e.g. anconda type thing)

Hope it helps.

Duck answered 26/10, 2016 at 21:5 Comment(0)
A
4

I had similiar problems and it was due to Anaconda messing up

I simply had to execute the following command:

conda remove libtiff

I installed opecv via:

sudo apt-get install opencv-dev

and libtiff via:

sudo apt-get install libtiff4-dev
Arbogast answered 15/6, 2017 at 12:38 Comment(0)
D
3

Old question but still without an answer so here it goes (I came across the same error today):

  1. That is not why the linker fails. If it was able to find libtiff.so.5 it would have linked just fine.

  2. @ vs @@ is just a way to track difference versions of the function. More details here https://sourceware.org/binutils/docs/ld/VERSION.html

  3. LIBTIFF_4.0 means it is that specific version of TIFFOpen that is required when dynamically loading the symbol.

  4. That is probably a good way to fix the issue. It's likely that without the libtiff-dev package the libtiff.so symbolic linked file doesn't exit in /usr/lib/x86_64-linux-gnu/ so the linker will not be able to find the library (it knows nothing about libtiff.so.5 unless you tell it explicitly).

  5. a. You may be able to test 4. by invoking the linker command line yourself from the command line. If you compiled caffe with cmake you'll find the linker command under tools/CMakeFiles/caffe.bin.dir/link.txt. Just add /usr/lib/x86_64-linux-gnu/libtiff.so.5 to the command line and it should work.

    b. Alternatively manually create the symbolic link /usr/lib/x86_64-linux-gnu/libtiff.so

    c. install the dev package, which should do that for you. Also make sure that cmake knows about /usr/lib/x86_64-linux-gnu/ by specify extra library path

    d. check that there are no other libtiff.so library lurking in your system if previous steps don't work (e.g. anconda type thing)

Hope it helps.

Duck answered 26/10, 2016 at 21:5 Comment(0)
S
2

Install libtiff4-dev:

sudo apt-get install libtiff4-dev

Solution answered 26/3, 2015 at 9:22 Comment(1)
Actually, I tried install version 4. But that didn't solve the problem. The library that libopencv_highgui.so.2.4.8 would look for is libtiff.so.5. By the way, Ubuntu 14.04 doesn't provide libtiff4. libtiff4-dev files. Unless, I compile OpenCV for myself.Magnetics
S
1

This is what worked for me: Go to Tiff website, and follow the instructions to download Tiff and build it, and install it. Then in your make file add this:

-L/[path to libtiff.so] -ltiff

If you want to know the path to the libtiff.so try this:

sudo find /usr/ -name libtiff.so
Seavir answered 6/10, 2016 at 17:12 Comment(0)
H
0

As you can see in

62: 0000000000000000 0 FUNC GLOBAL DEFAULT UND TIFFOpen@LIBTIFF_4.0 (9)

there's an UND which I think means undefined. I guess when ubuntu is producing libopencv_highgui, it fails to find TIFFOpen@LIBTIFF 4.0. So I think I should have libtiff at hand and compile libopencv_xxx again.

I like to include things in conda. So I install opencv again with conda, and point my LIBRARY_PATH to the conda lib directory and things go well.

Haberdashery answered 31/8, 2017 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.