Build HDF5 with static runtime

git checkout hdf5-1_13_0

mkdir build && cd build
cmake -A x64  \
-DBUILD_SHARED_LIBS=OFF \
-DHDF5_BUILD_CPP_LIB=ON \
-DHDF5_BUILD_TOOLS=OFF \
-DHDF5_BUILD_EXAMPLES=OFF \
-DHDF5_BUILD_TESTING=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW \
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" \
..

cmake --build . --config Release
cmake --install . --prefix C:/path/to/hdf5-1.13.0-mt

Properties > C/C++ > Code Generation > Runtime Library

set Multi-threaded (/MT) for release set Multi-threaded Debug (/MTd) for debug

MT

  • Check .obj files using /MT
      dumpbin /directives IOReaderExample.obj | findstr DEFAULTLIB
    

    You should see /DEFAULTLIB:"LIBCMT" Not /DefaultLIB:"MSVCRT". Sometime, DEFAULTLIB can’t be found. Try defaultlib.