金子邦彦研究室インストールWindows の種々のソフトウェア(インストール)Eigen 3 のインストール(ソースコードを使用)(Windows 上)

Eigen 3 のインストール(ソースコードを使用)(Windows 上)

Eigen は, 次の機能を持つ C++ テンプレートライブラリ.SSEを使うように最適化されている.

Windows で,Eigen 最新版をソースコードからビルドして,インストールする手順をスクリーンショット等で説明する.

目次

下に書いているように,vcpkg を利用してインストールすることができる. 特に問題がない場合には vcpkg の利用してのインストールを検討しよう. vcpkg使わずにインストールする必要がある場合は,このページの手順によりインストールを行うことができる.

Eigen 3 のインストール(vcpkg を利用)(Windows 上)

  1. Git のインストール

    Windows での Git のインストール: 別ページ »で説明している.

  2. Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022)のインストール

    Windows での Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022) のインストール: 別ページ »で説明している.

  3. vckpg のインストール

    Windows で,コマンドプロンプト管理者として実行.

    次のコマンドを実行

    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\")"
    )
    
  4. Eigen 3 のインストール

    次のコマンドを実行

    c:\vcpkg\vcpkg search eigen3
    c:\vcpkg\vcpkg install --triplet x64-windows eigen3
    powershell -command "[System.Environment]::SetEnvironmentVariable(\"EIGEN_ROOT\", \"C:\vcpkg\installed\x64-windows\", \"Machine\")"
    

前準備

Git のインストール(Windows 上)

Gitは,バージョン管理システム.ソースコードの管理や複数人での共同に役立つ.

サイト内の関連ページ

Windows での Git のインストール: 別ページ »で説明している.

関連する外部ページ

Git の公式ページ: https://git-scm.com/

CMake のインストール(Windows 上)

CMake はビルドツールである.

サイト内の関連ページ

Windows での cmake のインストール: 別ページ »で説明している.

関連する外部ページ

CMake の公式ダウンロードページ: https://cmake.org/download/

Build Tools for Visual Studio 2022,NVIDIA ドライバ,NVIDIA CUDA ツールキット,NVIDIA cuDNN のインストール(Windows 上)

サイト内の関連ページ

Windows での Build Tools for Visual Studio 2022NVIDIA ドライバNVIDIA CUDA ツールキット 11.8,NVIDIA cuDNN v8.6 のインストールと動作確認: 別ページ »で説明している.

関連する外部ページ

eigen のインストール(Build Tools for Visual Studio を利用)(Windows 上)

Boost のインストール

(オプション)OpenBLAS のインストール

必ずしも必要ではないが,必要になったときはインストールする.

(オプション)数値演算ライブラリ等のインストール(vcpkg を使用)

必ずしも必要ではないが,必要になったときはインストールする.

  1. 事前にvcpkg のインストールを行っておく.
  2. コマンドプロンプトを管理者として開き次のコマンドを実行する.
    c:\vcpkg\vcpkg --triplet x64-windows install blas fftw3[sse,sse2,avx,avx2,threads] gmp hwloc metis mpfr  openblas[threads] pthread superlu
    
  3. Windowsシステム環境変数 Pathに,c:\vcpkg\installed\x64-windows\bin追加することにより,パスを通す

    Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

    次のコマンドを実行

    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\vcpkg\installed\x64-windows\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    

eigen のインストール(Windows 上)

前もって,eigen をインストールするディレクトリを決めておく

このページでは,c:\eigen 下にインストールするものとして説明する.

  1. Windows で,コマンドプロンプト管理者として実行.

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. eigen の作業ディレクトリを削除する(以前作業したときのものが残っていたら削除したいため)
    C:
    cd %HOMEPATH%
    rmdir /s /q eigen
    

    [image]
  3. eigen のソースコードをダウンロード
    cd %HOMEPATH%
    git clone https://gitlab.com/libeigen/eigen.git
    

    [image]
  4. cmake の実行

    cmake でのオプションについて

    cmake のオプションの 「Visual Studio 17 2022」のところは, 使用する Visual Studio のバージョンにあわせること. Visual Studio 2022 のときは,「Visual Studio 17 2022」. Visual Studio 2019 のときは,「Visual Studio 16 2019

    cmake の実行手順例は次の通り

    cd %HOMEPATH%
    cd eigen
    rmdir /s /q build
    mkdir build
    cd build
    del CMakeCache.txt
    cmake .. -G "Visual Studio 17 2022" -A x64 -T host=x64 ^
        -DCMAKE_BUILD_TYPE=Release ^
        -DBoost_INCLUDE_DIR="%Boost_INCLUDE_DIR%" ^
        -DCUDA_NVCC_FLAGS="-allow-unsupported-compiler" ^
        -DCMAKE_INSTALL_PREFIX="c:/eigen" ^
        -DEIGEN_TEST_CUDA=ON 
    

    [image]
    (以下省略)

    上に示した「実行手順例」でのcmake でのオプションを調整するとしたら

  5. cmake の実行結果の確認

    ※ 下の通りになるとは限らない.エラーメッセージが出るなど場合は,前で cmake を実行したときの設定を変えてやり直す

    [image]
  6. ソースコードからビルドし、インストールする
    cmake --build. --config RELEASE
    cmake --build. --config RELEASE --target INSTALL
    
  7. 実行結果の確認

    [image]
  8. Windowsシステム環境変数 EIGEN_ROOT に,c:\eigen を設定

    次のコマンドを実行

    powershell -command "[System.Environment]::SetEnvironmentVariable(\"EIGEN_ROOT\", \"c:\eigen\", \"Machine\")"