我正在使用 C++ 和 Cmake 编译器进行编码,但在运行代码期间,终端上显示以下错误:
In file included from /home/alex/Downloads/Examples/Example1/main.cc:11:0:
/home/alex/Downloads/Examples/Example1/writeSolutions.h:3:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
CMakeFiles/main.dir/build.make:62: recipe for target 'CMakeFiles/main.dir/main.cc.o' failed
make[3]: *** [CMakeFiles/main.dir/main.cc.o] Error 1
CMakeFiles/Makefile2:195: recipe for target 'CMakeFiles/main.dir/all' failed
make[2]: *** [CMakeFiles/main.dir/all] Error 2
CMakeFiles/Makefile2:271: recipe for target 'CMakeFiles/run.dir/rule' failed
make[1]: *** [CMakeFiles/run.dir/rule] Error 2
Makefile:196: recipe for target 'run' failed
make: *** [run] Error 2**
我已在互联网上尝试了很多方法来解决这个问题,但没有任何新成果。
答案1
我问过我的论坛,得到了这样的答案:
HDF5 需要单独下载/安装。在此了解更多信息:support.hdfgroup.org/HDF5/
你可以从他们的网站下载,也可以使用包管理器来安装。记得安装开发版本。
当您使用 cmake 配置 deal.II 时,请使用以下参数:
-DDEAL_II_WITH_HDF5=开启
另外,在调用 cmake 时,您可能需要使用这些参数(替换正确的路径)为其提供以下一些目录:
-DHDF5_DIR=/路径/到/hdf5
-DHDF5_LIBRARY=/路径/到/hdf5/库
-DHDF5_HL_LIBRARY=/路径/到/hdf5_hl_library
-DHDF5_PUBCONF=/path/to/H5pubconf.h(另请参阅www.dealii.org/developer/readme.html)
但我还没有配置如何执行这些步骤。
答案2
它告诉您在源文件中/home/alex/Downloads/Examples/Example1/writeSolutions.h
,它正在尝试#include <hdf5.h>
,但找不到该文件。通过使用apt-cache search hdf5
,我找到了(除其他外)以下软件包:
libhdf5-10 - Hierarchical Data Format 5 (HDF5) - runtime files - serial version
libhdf5-10-dbg - Hierarchical Data Format 5 (HDF5) - Debug package
libhdf5-cpp-11 - Hierarchical Data Format 5 (HDF5) - C++ libraries
libhdf5-cpp-11-dbg - Hierarchical Data Format 5 (HDF5) - C++ Debug package
libhdf5-dev - Hierarchical Data Format 5 (HDF5) - development files - serial version
libhdf5-doc - Hierarchical Data Format 5 (HDF5) - Documentation
libhdf5-serial-dev - transitional dummy package
libhe5-hdfeos-dev - Development files for the HDF-EOS5 library
libhe5-hdfeos0 - Earth Observation System extensions to HDF5
libpbihdf - tools for handling PacBio hdf5 files
libpbihdf-dev - tools for handling PacBio hdf5 files (development files)
libhdf5-7 - Hierarchical Data Format 5 (HDF5) - runtime files - serial version
您需要安装该libhdf5-dev
包才能获得hdf5.h
。
通过搜索packages.ubuntu.com我为您找到了这些包:
You have searched for files named hdf5.h in suite xenial, all sections, and all architectures. Found 6 results.
File Packages
/usr/include/flann/io/hdf5.h libflann-dev
/usr/include/hdf5/mpich/hdf5.h libhdf5-mpich-dev
/usr/include/hdf5/openmpi/hdf5.h libhdf5-openmpi-dev
/usr/include/hdf5/serial/hdf5.h libhdf5-dev
/usr/include/opencv2/flann/hdf5.h libopencv-flann-dev
/usr/include/shark/Data/HDF5.h libshark-dev