hdf5 目录没有serial_hdf5.h在Ubuntu和CMake下没有这样的文件或目录

bd96500e110b49cbb3cd949968f18be7.png

I have already installed HDF5 under Ubuntu :

sudo apt install libhdf5-dev

I have a Qt program using HDF5 that compiles fine under CentOS 7 but not under Ubuntu :

erreur : hdf5.h: No such file or directory #include

^~~~~~~~

I am using CMake to generate the build files and in it, I didn't need to handle HDF5 for the CentOS build.

I added this part that I found on the web to the CMake script but I still have a compile error.

FIND_PACKAGE(ZLIB)

FIND_LIBRARY(HDF5_LIBRARY hdf5 ...)

FIND_LIBRARY(HDF5_HL_LIBRARY hdf5_hl ...)

IF(NOT TARGET hdf5 AND NOT TARGET hdf5_hl)

ADD_LIBRARY(hdf5 SHARED IMPORTED)

ADD_LIBRARY(hdf5_hl SHARED IMPORTED)

ENDIF()

SET_TARGET_PROPERTIES(hdf5 PROPERTIES IMPORTED_LOCATION ${HDF5_LIBRARY})

SET_TARGET_PROPERTIES(hdf5_hl PROPERTIES IMPORTED_LOCATION

${HDF5_HL_LIBRARY})

SET(HDF5_LIBRARIES hdf5 hdf5_hl ${ZLIB_LIBRARIES} m)

What can I add to the script to fix the include problem ?

with "locate", I found different hdf5.h :

/usr/include/hdf5/mpich/hdf5.h

/usr/include/hdf5/openmpi/hdf5.h

/usr/include/hdf5/serial/hdf5.h

I really want to know what "libhdf5-dev" refers to ? and why HDF5 is not provided correctly under Ubuntu (it's crazy !)

解决方案

Under Ubuntu, I was forced to add MPI to the CMake script. I don't like this solution but its CMake and Ubuntu fault...

find_package(HDF5)

find_package(MPI)

....

target_link_libraries(${binary} ${MPI_LIBRARIES} ${HDF5_LIBRARIES} ... )

target_include_directories(${binary} PRIVATE ${HDF5_INCLUDE_DIRS})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值