Caffe: Cannot find -lhdf5_hl and -lhdf5 : Ubuntu 16.04

Created on 20 Jun 2016  ·  12Comments  ·  Source: BVLC/caffe

I'm trying to get caffe installed on a new Ubuntu 16.04 install. (i want to do a CPU only compile. )

Initially, i installed all the dependencies following these instructions: https://gist.github.com/titipata/f0ef48ad2f0ebc07bcb9

But when i tried make, I got an initial error saying hdf5 not found. So i followed some instructions i found online to make this change to the make file.

Whatever else you find you need goes here.
-- +INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
-- +LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

++ +INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
++ +LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

That got rid of the hdf5 error. But now I hit this other hdf5 error

CXX src/caffe/util/hdf5.cpp
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:563: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

any assistance would be appreciated. thank you!

Most helpful comment

@KarthikGanesan88 Did you do the following steps?

cd /usr/lib/x86_64-linux-gnu

sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so

sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

In Ubuntu 16.04, the file versions are different. Visit /usr/lib/x86_64-linux-gnu/ and list the contents. The versions are 10.1.0 and 10.0.2 respectively.

In my installation I did sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so and sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so and caffe was able to locate libhdf5 and libhdf5_hl.

All 12 comments

@KarthikGanesan88 Additional steps in this installation guide for Ubuntu 16.04 have solved the issue for me.

@ergysr Hi, Thank you for your help, but I'm afraid the issue still persists.

  • Based on these instructions, i mostly had to install a lot more of the prerequisites. However, the changes to the makefile were things I already tried before. Those fixed my first error of not being able to compile the hdf5 files.
  • I didnt include the use pycaffe or cuda options since I just want to try out using the C options on my CPU. But just to follow the instructions, i tried to compile with python and got an error, so i went back to not doing an install with python support.

All in all, im afraid im still stuck at this point! The additional steps solved the 'cannot find hdf5.h' error i had earlier but not this correct hdf5 error!

@KarthikGanesan88 Did you do the following steps?

cd /usr/lib/x86_64-linux-gnu

sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so

sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

In Ubuntu 16.04, the file versions are different. Visit /usr/lib/x86_64-linux-gnu/ and list the contents. The versions are 10.1.0 and 10.0.2 respectively.

In my installation I did sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so and sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so and caffe was able to locate libhdf5 and libhdf5_hl.

@ergysr Hi, Thank you so much! that was indeed what I needed. When i copied the commands, it failed to replace the file so i had to manually delete both .so files and rerun the commands with the correct version numbers and I was able to build caffe!

@ergysr Thank u! It worked,so great!

Where can I delete the .so files manually? My installation did not replace the files either.

if the command tell you "ln: failed to create symbolic link 'libhdf5.so': File exists", do the following steps:
sudo ln -sf libhdf5_serial.so libhdf5.so
sudo ln -sf libhdf5_serial_hl.so libhdf5_hl.so

cd /usr/lib/x86_64-linux-gnu
root@esense9:/usr/lib/x86_64-linux-gnu#
root@esense9:/usr/lib/x86_64-linux-gnu# sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
ln: failed to create symbolic link 'libhdf5.so': File exists
root@esense9:/usr/lib/x86_64-linux-gnu#
root@esense9:/usr/lib/x86_64-linux-gnu# sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so
ln: failed to create symbolic link 'libhdf5_hl.so': File exists
root@esense9:/usr/lib/x86_64-linux-gnu#
root@esense9:/usr/lib/x86_64-linux-gnu#

how to find version number for caffe

@Kewenjing1020@ergysr
My problem is solved.
Thanks!

hello,
i've same problem with Raspian.

LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld : ne peut trouver -lhdf5_hl
/usr/bin/ld : ne peut trouver -lhdf5
/usr/bin/ld : ne peut trouver -lopencv_imgcodecs
collect2: error: ld returned 1 exit status
Makefile:572 : la recette pour la cible « .build_release/lib/libcaffe.so.1.0.0 » a échouée
make: * [.build_release/lib/libcaffe.so.1.0.0] Erreur 1

the files are present in /usr/lib/arm-linux-gnueabihf

how to able to locate libhdf5 and libhdf5_hl ?

thank you all

(i'm french, sry for my english :p )

I am installing Caffe on my Jetson TX2. For me this was slightly different. I used the following:

cd /usr/lib/aarch64-linux-gnu/
sudo ln -s libhdf5_serial.so.10 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
sudo ln -s libboost_python-py35.so libboost_python3.so
Was this page helpful?
0 / 5 - 0 ratings