TRIQS/h5 1.3.0
C++ interface to HDF5
|
h5 is a compiled library.
You can either
To use h5 in your own C++
code, you simply have to include the relevant header files. For example:
If you use CMake to build your source code, it is recommended to fetch the h5 directly from the Github repository using CMake's FetchContent module:
If you need to use some of the HDF5 C library features directly, you can simply link to it via h5::hdf5
.
Note that the above will also build goolgetest and the unit tests for h5. To disable this, you can put set(Build_Tests OFF CACHE BOOL "" FORCE)
before fetching the content or by specifying -DBuild_Tests=OFF
on the command line.
If you have already installed h5 on your system by following the instructions from the Installation page, you can also make use of CMake's find_package command. This has the advantage that you don't need to download anything, i.e. no internet connection is required. Furthermore, you only need to build the library once and can use it in multiple independent projects.
Let's assume that h5 has been installed to path_to_install_dir
. Then linking your project to h5 with CMake is as easy as
In case, CMake cannot find the package, you might have to tell it where to look for the h5-config.cmake
file by setting the variable h5_DIR
to path_to_install_dir/lib/cmake/h5
or by sourcing the provided h5vars.sh
before running CMake:
You can also integrate h5 into your CMake project by placing the entire source tree in a subdirectory and call add_subdirectory()
:
Here, it is assumed that the h5 source tree is in a subdirectory deps/h5
relative to your CMakeLists.txt
file.