问题描述
我已经在Ubuntu下安装了HDF5:
I have already installed HDF5 under Ubuntu :
sudo apt install libhdf5-dev
我有一个使用HDF5的Qt程序,该程序可以在CentOS 7下很好地编译,而在Ubuntu下却没有:
I have a Qt program using HDF5 that compiles fine under CentOS 7 but not under Ubuntu :
我使用CMake生成构建文件,在其中,我不需要为CentOS构建处理HDF5。
I am using CMake to generate the build files and in it, I didn't need to handle HDF5 for the CentOS build.
I将我在网上找到的这一部分添加到了CMake脚本中,但是仍然出现编译错误。
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 ?
带有 locate,我发现了不同的hdf5.h:
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
我真的很想知道 libhdf5 -dev是指?以及为什么在Ubuntu下无法正确提供HDF5(这太疯狂了!)
I really want to know what "libhdf5-dev" refers to ? and why HDF5 is not provided correctly under Ubuntu (it's crazy !)
推荐答案
在Ubuntu下,我被迫将MPI添加到CMake脚本。我不喜欢这种解决方案,但是它的CMake和Ubuntu错误...
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})
还有一个问题:
libhdf5实际上,-dev是串行版本
libhdf5-dev is, in fact, the serial version https://packages.ubuntu.com/xenial/amd64/libhdf5-dev/filelist
这篇关于hdf5.h在Ubuntu和CMake下没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!