I'm attempting to compile a binary file requiring the HDF5 library, but encountering linker errors like:
/usr/bin/ld: lib/libBVCio.so: undefined reference to `H5::StrType::StrType(H5::PredType const&, unsigned long const&)@HDF5_CPP_1.8.13'
/usr/bin/ld: lib/libBVCio.so: undefined reference to `H5::Attribute::write(H5::DataType const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@HDF5_CPP_1.8.15.1'
...
Each error message references a function with a version tag, such as HDF5_CPP_1.8.9, indicating the version of the function. However, even though I've manually installed HDF5 1.8.16 which I downloaded here, the version tags remain consistently "Base". For example:
objdump -T libhdf5_cpp.so.11 | c++filt | grep StrType::StrType
00000000000545ac g DF .text 000000000000003c Base H5::StrType::StrType(H5::StrType const&)
0000000000054460 g DF .text 0000000000000086 Base H5::StrType::StrType(H5::PredType const&, unsigned long const&)
In contrast, checking HDF5 1.10.7 reveals the expected version tags, such as HDF5_CPP_1.8.9:
objdump -T libhdf5_cpp.so.103 | c++filt | grep StrType::StrType
0000000000052310 g DF .text 000000000000001d HDF5_CPP_1.8.9 H5::StrType::StrType(H5::StrType const&)
...
I followed the instructions in the INSTALL document to build and install HDF5 1.8.16 from source, using commands like:
tar -xvf hdf5-1.8.16.tar
cd hdf5-1.8.16
./configure --prefix=/home/ethankao/Software/hdf5-1.8.16/build --enable-fortran --enable-cxx
make
make check
make install prefix=/home/ethankao/Software/hdf5-1.8.16/build
make check-install
I think if the version tags are correct, then there should be no such undefined reference errors. It looks like the way I configure the make file is problematic. If I could add or activate the version script, then there should be the version tag? Could you please advise on resolving this issue? Thank you.
Below is the configuration of the my two HDF5 libraries.
1. The manually installed 1.8.16
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.8.16
Configured on: Mon Mar 18 16:20:25 CET 2024
Configured by: ethankao@Prudens
Configure mode: production
Host system: x86_64-unknown-linux-gnu
Uname information: Linux Prudens 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Byte sex: little-endian
Libraries: static, shared
Installation point: /home/ethankao/Software/hdf5-1.8.16/build
Compiling Options:
------------------
Compilation Mode: production
C Compiler: /usr/bin/gcc
CFLAGS:
H5_CFLAGS: -std=c99 -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -O -finline-functions
AM_CFLAGS:
CPPFLAGS:
H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -DNDEBUG -UH5_DEBUG_API
AM_CPPFLAGS: -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE
Shared C Library: yes
Static C Library: yes
Statically Linked Executables: no
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries: -lz -ldl -lm
Archiver: ar
Ranlib: ranlib
Debugged Packages:
API Tracing: no
Languages:
----------
Fortran: yes
Fortran Compiler: /usr/bin/gfortran
Fortran 2003 Compiler:
Fortran Flags:
H5 Fortran Flags:
AM Fortran Flags:
Shared Fortran Library: yes
Static Fortran Library: yes
C++: yes
C++ Compiler: /usr/bin/g++
C++ Flags:
H5 C++ Flags:
AM C++ Flags:
Shared C++ Library: yes
Static C++ Library: yes
Features:
---------
Parallel HDF5: no
High Level library: yes
Threadsafety: no
Default API Mapping: v18
With Deprecated Public Symbols: yes
I/O filters (external): deflate(zlib)
MPE: no
Direct VFD: no
dmalloc: no
Clear file buffers before write: yes
Using memory checker: no
Function Stack Tracing: no
Strict File Format Checks: no
Optimization Instrumentation: no
2. Automatically installed 1.10.7
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.10.7
Configured on: Wed, 08 Dec 2021 23:33:27 +0000
Configured by: Debian
Host system: x86_64-pc-linux-gnu
Uname information: Debian
Byte sex: little-endian
Installation point: /usr
Flavor name: serial
Compiling Options:
------------------
Build Mode: production
Debugging Symbols: no
Asserts: no
Profiling: no
Optimization Level: high
Linking Options:
----------------
Libraries: static, shared
Statically Linked Executables:
LDFLAGS: -Wl,-Bsymbolic-functions -flto=auto -Wl,-z,relro
H5_LDFLAGS: -Wl,--version-script,$(top_srcdir)/debian/map_serial.ver
AM_LDFLAGS:
Extra libraries: -lcrypto -lcurl -lpthread -lsz -lz -ldl -lm
Archiver: ar
AR_FLAGS: cr
Ranlib: x86_64-linux-gnu-ranlib
Languages:
----------
C: yes
C Compiler: /usr/bin/gcc
CPPFLAGS: -Wdate-time -D_FORTIFY_SOURCE=2
H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -DNDEBUG -UH5_DEBUG_API
AM_CPPFLAGS:
C Flags: -g -O2 -ffile-prefix-map=$(top_srcdir)=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security
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 -Wimplicit-fallthrough=5 -Wrestrict -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -Wattribute-alias=2 -Wmissing-profile -fstdarg-opt -s -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 -Werror=bad-function-cast -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=missing-prototypes -Werror=nested-externs -Werror=old-style-definition -Werror=packed -Werror=pointer-sign -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=strict-prototypes -Werror=switch -Wunused-function -Wunused-variable -Wunused-parameter -Wcast-align -Wunused-but-set-variable -Wformat -Werror=incompatible-pointer-types -Werror=shadow -Wcast-function-type -Wmaybe-uninitialized
AM C Flags:
Shared C Library: yes
Static C Library: yes
Fortran: yes
Fortran Compiler: /usr/bin/gfortran
Fortran Flags: -g -O2 -ffile-prefix-map=$(top_srcdir)=. -flto=auto -ffat-lto-objects -fstack-protector-strong
H5 Fortran Flags: -std=f2008 -Waliasing -Wall -Wcharacter-truncation -Wextra -Wimplicit-interface -Wsurprising -Wunderflow -pedantic -Warray-temporaries -Wintrinsics-std -Wimplicit-procedure -Wreal-q-constant -Wfunction-elimination -Wrealloc-lhs -Wrealloc-lhs-all -Wno-c-binding-type -Wuse-without-only -Winteger-division -Wfrontend-loop-interchange -s -O3
AM Fortran Flags:
Shared Fortran Library: yes
Static Fortran Library: yes
C++: yes
C++ Compiler: /usr/bin/g++
C++ Flags: -g -O2 -ffile-prefix-map=$(top_srcdir)=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security
H5 C++ Flags: -Wall -Wcast-qual -Wconversion -Wctor-dtor-privacy -Weffc++ -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wno-format-nonliteral -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wreorder -Wshadow -Wsign-promo -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 -Wopenmp-simd -Warray-bounds=2 -Wduplicated-cond -Whsa -Wnormalized -Wnull-dereference -Wunused-const-variable -Walloca -Walloc-zero -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wimplicit-fallthrough=5 -Wrestrict -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -Wattribute-alias=2 -Wmissing-profile -fstdarg-opt -s -O3 -Wcast-align -Wmissing-declarations -Werror=packed -Werror=redundant-decls -Werror=switch -Wunused-but-set-variable -Werror=unused-function -Werror=unused-variable -Wunused-parameter -Werror=shadow
AM C++ Flags:
Shared C++ Library: yes
Static C++ Library: yes
Java: yes
Java Compiler: /usr/bin/java (openjdk 11.0.13 2021-10-19)
Features:
---------
Parallel HDF5: no
Parallel Filtered Dataset Writes: no
Large Parallel I/O: no
High-level library: yes
Build HDF5 Tests: yes
Build HDF5 Tools: yes
Threadsafety: yes
Default API mapping: v18
With deprecated public symbols: yes
I/O filters (external): deflate(zlib),szip(encoder)
MPE: no
Direct VFD: no
Mirror VFD: no
(Read-Only) S3 VFD: yes
(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