I'm trying to use execute a basic C script (here). I believe I've installed the HDF5 library correctly using:
sudo apt install libhdf5-dev
When I first tried to compile the code using:
g hdf5_simple.cpp -lhdf5 -lhdf5_cpp -o hdf5_simple
I got:
hdf5_simple.cpp:3:10: fatal error: H5Cpp.h: No such file or directory
Simple enough, I try:
g -I/usr/include/hdf5/serial/ hdf5_simple.cpp -lhdf5 -lhdf5_cpp -o hdf5_simple
And it complies with no issues, but when I try to run it is get:
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.10.4, library is 1.13.0
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.13.0
Configured on: Wed Dec 22 18:04:31 UTC 2021
Configured by: ***@***
Host system: x86_64-unknown-linux-gnu
Uname information: Linux *** 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Byte sex: little-endian
Installation point: /usr/local/hdf5
Compiling Options:
------------------
Build Mode: production
Debugging Symbols: no
Asserts: no
Profiling: no
Optimization Level: high
Linking Options:
----------------
Libraries: static, shared
Statically Linked Executables:
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries: -lz -ldl -lm
Archiver: ar
AR_FLAGS: cr
Ranlib: ranlib
Languages:
----------
C: yes
C Compiler: /usr/bin/mpicc ( MPICH version 3.3.2 Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.4.0-3ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c ,go,brig,d,fortran,objc,obj-c --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu built with gcc version 8.4.0 (Ubuntu 8.4.0-3ubuntu2))
CPPFLAGS:
H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -DNDEBUG -UH5_DEBUG_API
AM_CPPFLAGS:
C Flags:
H5 C Flags: -std=c99 -Wall -Wcast-qual -Wconversion -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wno-c -compat -Wno-format-nonliteral -Wshadow -Wundef -Wwrite-strings -pedantic -Wlarger-than=2560 -Wlogical-op -Wframe-larger-than=16384 -Wpacked-bitfield-compat -Wsync-nand -Wstrict-overflow=5 -Wno-unsuffixed-float-constants -Wdouble-promotion -Wtrampolines -Wstack-usage=8192 -Wmaybe-uninitialized -Wdate-time -Warray-bounds=2 -Wc99-c11-compat -Wduplicated-cond -Whsa -Wnormalized -Wnull-dereference -Wunused-const-variable -Walloca -Walloc-zero -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wrestrict -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -fstdarg-opt -s -Wbad-function-cast -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-sign -Wpointer-to-int-cast -Wint-to-pointer-cast -Wredundant-decls -Wstrict-prototypes -Wswitch -Wunused-function -Wunused-variable -Wunused-parameter -Wcast-align -Wunused-but-set-variable -Wformat -Wincompatible-pointer-types -Wint-conversion -Wshadow -Wcast-function-type -Wmaybe-uninitialized -Wno-aggregate-return -Wno-inline -Wno-missing-format-attribute -Wno-missing-noreturn -Wno-overlength-strings -Wno-jump-misses-init -Wno-suggest-attribute=const -Wno-suggest-attribute=noreturn -Wno-suggest-attribute=pure -Wno-suggest-attribute=format -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc -O3
AM C Flags:
Shared C Library: yes
Static C Library: yes
Fortran: no
C : no
Java: no
Features:
---------
Parallel HDF5: yes
Parallel Filtered Dataset Writes: yes
Large Parallel I/O: yes
High-level library: yes
Dimension scales w/ new references: no
Build HDF5 Tests: yes
Build HDF5 Tools: yes
Threadsafety: no
Default API mapping: v114
With deprecated public symbols: yes
I/O filters (external): deflate(zlib)
MPE:
Map (H5M) API: no
Direct VFD: no
Mirror VFD: no
(Read-Only) S3 VFD: no
(Read-Only) HDFS VFD: no
dmalloc: no
Packages w/ extra debug output: none
API tracing: no
Using memory checker: no
Memory allocation sanity checks: no
Function stack tracing: no
Use file locking: best-effort
Strict file format checks: no
Optimization instrumentation: no
Bye...
Aborted (core dumped)
Following the notes at the top of the warning, I added #define DF5_DISABLE_VERSION_CHECK 1 and recompile and the same warning came up. Then I tried to add the path to LD_LIBRARY_PATH usingexport LD_LIBRARY_PATH="/usr/include/hdf5/serial/" but still no luck.
I'm not sure whats going wrong. Any help would be greatly appreciated.
CodePudding user response:
Try this:
g `pkg-config --cflags hdf5-serial` hdf5_simple.cpp `pkg-config --libs hdf5-serial` -lhdf5_cpp -o hdf5_simple
The command will allow you to build your program against the C monothreaded version.
For having ported hdf5 to Node.js (I am the author of gdal-async in Node.js), I can attest that it has some horrible quirks: it has two very important compilation options, the thread safety option and the C API. These two are not compatible and a stock tarball will refuse to build when both are enabled. The Debian/Ubuntu team went to extreme lengths to allow you to use both of them - as long as it is not at the same time - it is either C (they call this the high-level API) or multi-threading.
As if this was not enough, there is also the MPI-enabled version that you seem to mixing on top of it as I see from your configuration.
Do not disable any warning and checks and be very careful what you are linking your program with or you will be up for some very nasty surprises at runtime.
