HDF5 库段错误(不匹配 headers)

HDF5 library segfault (mismatching headers)

我在 ubuntu 上安装了 flann 和 libhdf5-serial-dev c++ 库。之后,我编译flann_example.cpp文件没有问题。但是,当我启动可执行文件时,我收到以下错误消息:

Warning! HDF5 library version mismatched error The HDF5 header files used to compile this application do not match the version used by the HDF5 library to which this application is linked. Data corruption or segmentation faults may occur if the application continues. This can happen when an application was compiled by one version of HDF5 but linked with a different version of static or shared HDF5 library. You should recompile the application or check your shared library related settings such as 'LD_LIBRARY_PATH'. You can, at your own risk, disable this warning by setting the environment variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'. Setting it to 2 or higher will suppress the warning messages totally. Headers are 1.8.16, library is 1.8.7 Bye... Abandon (core dumped)

我使用以下表达式来抑制此警告:

 cmake -HDF5_DISABLE_VERSION_CHECK=1 -H. -Bbuild

但是我还有这条消息。我用 ccmake 寻找可选标志 HDF5_DISABLE_VERSION_CHECK 来检查它是否设置为 1。但是我看不到这个标志。 有人可以帮我解决这个问题吗?

You can, at your own risk, disable this warning by setting the environment variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.

HDF5_DISABLE_VERSION_CHECK 是环境变量,不是编译器 #define 或 CMake 变量。在您的 shell:

中设置它
export HDF5_DISABLE_VERSION_CHECK=1
path/to/flann_example

HDF5_DISABLE_VERSION_CHECK=1 path/to/flann_example

但是,解决根本问题(库不匹配)可能会好得多。在 Ubuntu 上,如果您总是安装库的 Ubuntu 打包版本(通过 aptaptitude、Synaptic...)而不是自己安装库,这应该确保所有库版本都兼容。