方法1:首先确认安装hdf5包,安装使用sudo apt-get install libhdf5-dev
安装完成后重新编译,若仍然出现此错误,在/usr/lib中查找libhdf5.so软连接所在位置,一般在x86_64-linux-gnu/hdf5/serial/下,将此路径添加在Makefile.config相应位置处:
# 找到这行: LIB_DIRS := $(PYTHON_INCLUDE) /usr/local/lib /usr/lib
# 替换为: LIB_DIRS := $(PYTHON_INCLUDE) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
另外查看include头文件是否加载hdf5,如下。
# 找到这行: INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
# 替换为: INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
方法2:不用更改LIB_DIRS,在/usr/lib下简历libhdf5软连接。
sudo ln -sf /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/libhdf5.so
sudo ln -sf /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so.x /usr/lib/libhdf5.so.x,x表示数字,需要你自己查看。
方法3:(此方法不是只是解决了编译不报错,但你后续使用到hdf5时可能还会有问题,因为INCLUDE和LIB加载的都不是同一个东西)
需要sudo apt-get install libhdf5-serial-dev
修改Makefile 文件(注意不是)Makefile.config
将里面的
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