* Build the examples as C++11 to match the HDF5 C++ library The standalone examples build forces CMAKE_CXX_STANDARD 98, but H5public.h includes <cinttypes>, which requires C++11. Any C++ translation unit that includes hdf5.h is therefore affected, not just users of the C++ API, and the HDF5 C++ library itself is built as C++11 (config/flags/HDFCompilerCXXFlags.cmake). The C++ examples do not compile as a result, against static or shared HDF5 alike. Only the standalone build is affected, which is why this is not visible in ordinary use. The C++98 setting lives in BASIC_SETTINGS, and HDF5Examples/CMakeLists.txt skips that whole block when EXAMPLES_EXTERNALLY_CONFIGURED is set -- which HDF5 does for its own in-tree example build (config/cmake/HDF5ExampleCache.cmake). Built in tree, the examples inherit HDF5's C++11 and compile normally, and that is the path the CI workflows exercise. The standalone path, where the C++98 setting does apply, is driven by the release scripts rather than by the workflows, and has the C++ examples off by default. * Select the examples' HL, Fortran and C++ libraries on the right variable When the examples are built standalone against an installed HDF5, the HL, Fortran and C++ branches choose between the shared and static libraries using BUILD_SHARED_LIBS, while the C branch just above them uses H5EXAMPLE_USE_SHARED_LIBS. H5EXAMPLE_USE_SHARED_LIBS is what decides whether the "shared" or the "static" component is requested from find_package, so only the matching HDF5_<linkage>_<lang>_FOUND variables are ever set. BUILD_SHARED_LIBS cannot select a linkage on its own; it can only agree or fail to match. Of its four combinations with H5EXAMPLE_USE_SHARED_LIBS, three produce no observable difference. In the fourth, H5EXAMPLE_USE_SHARED_LIBS=ON with BUILD_SHARED_LIBS unset, the shared branch is not taken and the static branch cannot be, so the HL, Fortran and C++ examples are disabled with "libs not found" even though the libraries are installed and were found. Use H5EXAMPLE_USE_SHARED_LIBS, which is the declared option and is already what the C branch uses. A build driven through config/examples/CTestScript.cmake does not reach the broken combination, because it configures with HDF5Examples/config/cmake/cacheinit.cmake, which forces BUILD_SHARED_LIBS=ON. A direct cmake invocation without that cache file does. In either case the HL, Fortran and C++ examples are off by default, so this is only visible once they are enabled. BUILD_SHARED_LIBS remains documented as a user option in config/examples/HDF5_Examples_options.cmake but no longer influences library selection; that comment should be revisited separately.
HDF5 Examples
Please refer to the Using_CMake.txt file for CMake instructions.
Note that this HDF5Examples directory structure is also provided as a stand-alone project distributed with library binaries as well as compiled and tested during a HDF5 Library build.
This repository contains a high-performance library's example code that demonstrate the HDF5® data model API. The HDF5® data model has been adopted across many industries and this implementation has become a de facto data management standard in science, engineering, and research communities worldwide.
The HDF Group is the developer, maintainer, and steward of HDF5 software. Find more information about The HDF Group, the HDF5 Community, and other HDF5 software projects, tools, and services at The HDF Group's website.
We suggest using the presets method with CMake for building the examples. However, if you prefer to use the h5cc pkg-config wrappers, you can use the following commands to build the examples:
export HDF5_HOME="hdf5 installation root"
export PKG_CONFIG_PATH="$HDF5_HOME/lib/pkgconfig"
export LD_LIBRARY_PATH="$HDF5_HOME/lib:$LD_LIBRARY_PATH"
export PATH="$HDF5_HOME/bin:$PATH"
Then, you can compile the examples with:
h5cc -o example1 example1.c
h5c++ -o example2 example2.cpp
h5fc -o example3 example3.f90
For Java examples with Maven integration, see the JAVA/README-MAVEN.md file for complete instructions on using the org.hdfgroup:hdf5-java-examples Maven artifact.
The test-pc.sh script can test the examples with the h5*cc pkg-config wrappers with: cd <path to examples> export HDF5_HOME="hdf5 installation root"; sh ./test-pc.sh <path to examples> <path to build dir> . Notice that period (.) at the end of the command is important, it tells the script to use the current directory as the source directory.
HELP AND SUPPORT
Information regarding Help Desk and Support services is available at
FORUM and NEWS
The HDF Forum is provided for public announcements and discussions of interest to the general HDF5 Community.
-
News and Announcements https://forum.hdfgroup.org/c/news-and-announcements-from-the-hdf-group
-
HDF5 Topics https://forum.hdfgroup.org/c/hdf5
These forums are provided as an open and public service for searching and reading. Posting requires completing a simple registration and allows one to join in the conversation. Please read the instructions pertaining to the Forum's use and configuration.
HDF5 SNAPSHOTS, PREVIOUS RELEASES AND SOURCE CODE
Full Documentation and Programming Resources for this HDF5 can be found at
https://support.hdfgroup.org/documentation/index.html
Periodically development code snapshots are provided at the following URL:
https://github.com/HDFGroup/hdf5/releases/tag/snapshot
Source packages for current and previous releases are located at:
Latest HDF5 release Previous releases
Development code is available at our Github location: