致命错误:H5Cpp.h:没有这样的文件或目录
fatal error: H5Cpp.h: No such file or directory
我正在尝试使用 HDF5 库编译一个应用程序。我通过 ubuntus 18.04 包管理器安装了库。我的 CMakeList 看起来像
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(hdf)
find_package(HDF5 REQUIRED COMPONENTS C CXX)
add_executable(hdf hdf.cpp)
target_link_libraries(hdf ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${HDF5_LIBRARIES})
set_property(TARGET hdf PROPERTY CXX_STANDARD 17)
message(STATUS "INCLUDE LOCATION" ${HDF5_INCLUDE_DIRS})
message(STATUS "version" ${HDF5_VERSION})
message(STATUS "DEFINITIONS" ${HDF5_DEFINITIONS})
message(STATUS "LIBRARIES" ${HDF5_LIBRARIES})
message(STATUS "HL_LIBRARIES" ${HDF5_HL_LIBRARIES})
运行 cmake,输出产量
HDF5: Using hdf5 compiler wrapper to determine C configuration
-- HDF5: Using hdf5 compiler wrapper to determine CXX configuration
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.0.1") found components: C CXX
-- INCLUDE LOCATION/usr/include/hdf5/serial
-- version1.10.0.1
-- DEFINITIONS-D_FORTIFY_SOURCE=2
-- LIBRARIES/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so/usr/lib/x86_64-linux-gnu/libpthread.so/usr/lib/x86_64-linux-gnu/libsz.so/usr/lib/x86_64-linux-gnu/libz.so/usr/lib/x86_64-linux-gnu/libdl.so/usr/lib/x86_64-linux-gnu/libm.so
-- HL_LIBRARIES
所以显然这些文件都找到了。
但是,如果我不尝试编译一个简单的示例并包含依赖项
#include "H5Cpp.h"
我得到
fatal error: H5Cpp.h: No such file or directory
#include "H5Cpp.h"
为什么?感谢帮助
必须显式将标头位置添加到 CMakeLists.txt:
include_directories(${HDF5_INCLUDE_DIRS})
有关更多详细信息,请参阅 include_directories 的文档。
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- c++库的公共头文件中应该包含什么
- 用c++从输入文件中读取另一行
- Cppcheck生成xml转储文件
- 读取文件的最后一行并输入到链接列表时出错
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- 如何将内容数组写入文本文件?
- 致命错误:H5Cpp.h:没有这样的文件或目录