Hello Caffe is a library for deeplearning. When trying to build that library under Ubuntu 15.04, the compilation fails with the message:

:~/App/caffe$ make all

PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/layer_factory.cpp
In file included from ./include/caffe/common_layers.hpp:10:0,
                 from ./include/caffe/vision_layers.hpp:10,
                 from src/caffe/layer_factory.cpp:6:
./include/caffe/data_layers.hpp:9:18: fatal error: hdf5.h: Aucun fichier ou dossier de ce type
 #include "hdf5.h"
compilation terminated.
Makefile:512: recipe for target '.build_release/src/caffe/layer_factory.o' failed
make: *** [.build_release/src/caffe/layer_factory.o] Error 1

The building failure seems to be Ubuntu specific. I have checked the different dependencies. I tried different workaround: writing the path of hdf5.h directly in the Makefile.config, building hdf5 from source...

Thanks for advices


1 Answer 1


install libhdf5-dev

add patch to libhdf5 in Makefile.config.

example: INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

  • +1 Found this searching and it fixed the issue. @Jean-Pat, please consider accepting this answer if it solved your problem. Jul 11, 2015 at 13:54
  • 1
    This fixes the missing include but the compile just fails later because it can't find the libs. Jul 19, 2015 at 11:33
  • @Alistair Buxton: I have made an addition to the answer, in order to show how to fix this issue, if it persists, even after updating the Makefile.config.
    – Codetoffel
    Oct 2, 2016 at 8:37
  • To me, this leads to another error: AR -o .build_release/lib/libcaffe.a LD -o .build_release/lib/libcaffe.so.1.0.0 /usr/bin/ld: cannot find -lhdf5_hl /usr/bin/ld: cannot find -lhdf5 collect2: error: ld returned 1 exit status Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
    – skyuuka
    Aug 23, 2018 at 22:17
  • This change in the Makefile.config fixed my issue: LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
    – skyuuka
    Aug 23, 2018 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.