Currently, I am trying to get caffe (this one: http://caffe.berkeleyvision.org/installation.html) running on my Ubuntu 16.04 machine. The error am getting when I try to call make is:

CXX src/caffe/layers/conv_layer.cpp
In file included from ./include/caffe/vision_layers.hpp:11:0,
                 from src/caffe/layers/conv_layer.cpp:3:
./include/caffe/data_layers.hpp:7:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
Makefile:552: recipe for target '.build_release/src/caffe/layers/conv_layer.o' failed
make: *** [.build_release/src/caffe/layers/conv_layer.o] Error 1

I found this thread as a solution to this for some people:
So I tried in my terminal:

$ sudo apt-get install cython
$ sudo apt-get install libhdf5-dev
$ sudo apt-get install python-h5py
$ HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ pip install h5py
$ pip install h5py

However the error remained. I did find that I had the file here:


How do I make c++ automatically find the file here? It can for example find glog without problem after I installed it using apt-get, but hdf5 seems different. Does anyone know why?

  • Are you building with cmake or autoconf (i.e. ./configure)? This is a known issue with the packaging of hdf5 development libraries on recent Debian-based distributions I think. – steeldriver Dec 14 '16 at 16:27
  • Well, I am building caffe with 'make' if that is what you mean – dimpol Dec 15 '16 at 10:18
  • No, I was really asking about the step before make: there is likely either a cmake variable that you can define (something like WITH_HDF5_INCLUDE_DIR) or an equivalent ./configure variable (something like --with-hdf5-include). Ultimately, you need to set an appropriate compile flag like CXXFLAGS=-I/usr/include/hdf5/serial. – steeldriver Dec 15 '16 at 19:52

Your Answer

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

Browse other questions tagged or ask your own question.