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'
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.
libtiff.so.5
has @@
in the symbol names instead of @
that made the linking errorlibopencv_highgui.so.2.4.8: undefined reference to 'TIFFIsTiled@LIBTIFF_4.0'
What's the difference between @
and@@
in symbol names?What's the meaning of the suffix LIBTIFF_4.0
of symbols names inlibtiff.so.5
?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.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.
Old question but still without an answer so here it goes (I came across the same error today):
That is not why the linker fails. If it was able to find libtiff.so.5 it would have linked just fine.
@ vs @@ is just a way to track difference versions of the function. More details here https://sourceware.org/binutils/docs/ld/VERSION.html
LIBTIFF_4.0 means it is that specific version of TIFFOpen that is required when dynamically loading the symbol.
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).
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.