I had just completed an install of caffe on a new laptop, but when I ran make all, I got the following error:
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:573: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
My fix for this was to change the LIBRARY_DIRS assignment in Makefile.config to include the location of the hdf5 libs:
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib / usr/lib/x86_64-linux-gnu/hdf5/serial
and now things seem to work (make runtest just passed 2097 tests)
I also added /usr/include/hdf5/serial to INCLUDE_DIRS:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
Operating system: Ubuntu 16.04.4
Compiler: gcc 5.4.0
Even after I added both LIBRARY_DIRS and INCLUDE_DIRS in Makefile.config as suggested above
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu/hdf5/serial
````
But, I still got this error:
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:573: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
I have seen in some posts that we need create symbolics to find the libraries because the lib names of ```hdf5``` on debian have a postfix "serial", therefore ```-lhdf5``` and ```-lhdf5_hl``` cannot be found.
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
But I am a user on a shared server, so I did not have ```sudo``` rights.
Also, a certain post suggested instead of changing symbolic links, we can just edit the ```Makefile``` in the caffe folder as such
--- LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+++ LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
```
Hope it'll help others searching for the solution
Most helpful comment
Even after I added both
LIBRARY_DIRSandINCLUDE_DIRSinMakefile.configas suggested above/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:573: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
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
--- LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+++ LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
```
Hope it'll help others searching for the solution