HDF5 は,階層データを扱うライブラリソフトウェア.
Windows で,HDF5 をソースコードからビルドして,インストールする手順を説明する. Build Tools for Visual Studio 2022(ビルドツール for Visual Studio 2022)を使用する. configure 版よりも CMake 版の方が Windows でのインストールが簡単だと判断している.
【目次】
HDF の利用条件などは、利用者が確認すること。次のWeb ページを活用してください
https://support.hdfgroup.org/products/licenses.html
下に書いているように,vcpkg を利用してインストールすることができる. 特に問題がない場合には vcpkg の利用してのインストールを検討しよう. vcpkg を使わずにインストールする必要がある場合は,このページの手順によりインストールを行うことができる.
Windows での Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022) のインストール: 別ページ »で説明している.
次のコマンドを実行
if not exist c:\vcpkg ( cd c:\ rmdir /s /q vcpkg git clone https://github.com/microsoft/vcpkg cd c:\vcpkg git pull .\bootstrap-vcpkg.bat .\vcpkg update .\vcpkg integrate install powershell -command "[System.Environment]::SetEnvironmentVariable(\"VCPKG_ROOT\", \"c:\vcpkg\", \"Machine\")" powershell -command "[System.Environment]::SetEnvironmentVariable(\"VCPKG_DEFAULT_TRIPLET\", \"x64-windows\", \"Machine\")" powershell -command "[System.Environment]::SetEnvironmentVariable(\"CMAKE_TOOLCHAIN_FILE\", \"c:/vcpkg/scripts/buildsystems/vcpkg.cmake\", \"Machine\")" powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"LIB\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\lib\"; [System.Environment]::SetEnvironmentVariable(\"LIB\", $oldpath, \"Machine\")" powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"INCLUDE\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\include\"; [System.Environment]::SetEnvironmentVariable(\"INCLUDE\", $oldpath, \"Machine\")" powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\vcpkg\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")" powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")" )
次のコマンドを実行
c:\vcpkg\vcpkg search hdf5 c:\vcpkg\vcpkg install --triplet x64-windows hdf5[cpp,tools,utils,zlib] zlib powershell -command "[System.Environment]::SetEnvironmentVariable(\"HDF5_ROOT\", \"C:\vcpkg\installed\x64-windows\", \"Machine\")"
Build Tools for Visual Studio 2017 (ビルドツール for Visual Studio 2017)もしくはVisual Studio 2017 を,前もってインストールしておく.NVIDIA CUDA の nvcc を機能させるため.
Build Tools for Visual Studio 2017 (ビルドツール for Visual Studio 2017) のインストール: 別ページ »で説明
Gitは,バージョン管理システム.ソースコードの管理や複数人での共同に役立つ.
【サイト内の関連ページ】
Windows での Git のインストール: 別ページ »で説明している.
【関連する外部ページ】
Git の公式ページ: https://git-scm.com/
CMake はビルドツールである.
【サイト内の関連ページ】
Windows での cmake のインストール: 別ページ »で説明している.
【関連する外部ページ】
CMake の公式ダウンロードページ: https://cmake.org/download/
Windows のスタートメニューで「Visual Studio 2017」の下の「VS2017 用 x64 Native Tools コマンドプロンプト」で起動する.(あるいは類似のものを探す)
cd %HOMEPATH% rmdir /s /q CMake-hdf5-1.10.5
cd %HOMEPATH% del CMake-hdf5-1.10.5.zip curl -O https://support.hdfgroup.org/ftp/HDF5/current/src/CMake-hdf5-1.10.5.zip rmdir /s /q CMake-hdf5-1.10.5 powershell Expand-Archive -DestinationPath . CMake-hdf5-1.10.5.zip
https://portal.hdfgroup.org/display/support/Building+HDF5+with+CMakeの記載に従う
cmake の実行手順例は次の通り
cd %HOMEPATH% cd CMake-hdf5-1.10.5 ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764,INSTALL_DIR="C:/hdf5" -C Release -V -O hdf5.log
次のような表示になる. 「100% tests passed. 0 tests failed out of 2681」のように表示される.
なお Build Tools for Visual Studio 2017 よりも新しいバージョン (2019 や 2022)を使うと,エラーが出て,続行できないようである.
次のように設定する
%HOMEPATH%\CMake-hdf5-1.10.5\hdf5-1.10.5
次のように追加する
%HOMEPATH%\CMake-hdf5-1.10.5\build\bin\Release