SuiteSparse,Metis のインストール(ソースコードを用いたインストール)(Windows 上)

SuiteSparse は,下記の機能を持つソフトウェアである.

UFconfig は,SuiteSparseQR, AMD, COLAMD, CCOLAMD, CHOLMOD, KLU, BTF, LDL, CXSparse, and UMFPACK のビルドに必要.

AMD は,疎行列の並び替えの機能を持ったソフトウェア. これは,Cholesky factorization や, 不完全 LU 分解 (LU factorization) の前処理として行うもの.

インストールでは,次のページに記載の手順を行う.そして,次のページで公開のプログラム等を使用している.

https://github.com/jlblancoc/suitesparse-metis-for-windows

【目次】

  1. 前準備
  2. SuiteSparse,Metis のインストール(ソースコードを用いたインストール)(Windows 上)

前準備

Build Tools for Visual Studio 2026 のインストール(Windows 上) [クリックして展開]

Build Tools for Visual Studio は,Visual Studio の IDE を含まない C/C++ コンパイラ,ライブラリ,ビルドツール等のコマンドライン向け開発ツールセットである。インストール済みの場合、この手順は不要である。

管理者権限コマンドプロンプトで以下を実行する。管理者権限のコマンドプロンプトを起動するには、Windows キーまたはスタートメニューから「cmd」と入力し、表示された「コマンドプロンプト」を右クリックして「管理者として実行」を選択する。

REM VC++ ランタイム
winget install --scope machine --id Microsoft.VCRedist.2015+.x64 -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/quiet /norestart"

REM Build Tools + Desktop development with C++(VCTools)+ 追加コンポーネント(一括)
winget install --scope machine --id Microsoft.VisualStudio.BuildTools -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "--quiet --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.VC.CMake.Project --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset --add Microsoft.VisualStudio.Component.Windows11SDK.26100"

--add で追加されるコンポーネント

上記のコマンドでは,まず Build Tools 本体と Visual C++ 再頒布可能パッケージをインストールし,次に setup.exe を用いて以下のコンポーネントを追加している。

インストール完了の確認

winget list Microsoft.VisualStudio.BuildTools

上記以外の追加のコンポーネントが必要になった場合は Visual Studio Installer で個別にインストールできる。

Visual Studio の機能を必要とする場合は、追加インストールできる。

Git のインストール(Windows 上) [クリックして展開]

管理者権限コマンドプロンプトで以下を実行する.管理者権限は,winget の --scope machine オプションでシステム全体にインストールするために必要となる.

REM Git をシステム領域にインストール
winget install --scope machine --id Git.Git -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=""icons,ext\reg\shellhere,assoc,assoc_sh"" /o:PathOption=Cmd /o:CRLFOption=CRLFCommitAsIs /o:BashTerminalOption=MinTTY /o:DefaultBranchOption=main /o:EditorOption=VIM /o:SSHOption=OpenSSH /o:UseCredentialManager=Enabled /o:PerformanceTweaksFSCache=Enabled /o:EnableSymlinks=Disabled /o:EnableFSMonitor=Disabled"

CMakeのインストール(Windows 上) [クリックして展開]

管理者権限コマンドプロンプトで以下を実行する。管理者権限のコマンドプロンプトを起動するには、Windows キーまたはスタートメニューから「cmd」と入力し、表示された「コマンドプロンプト」を右クリックして「管理者として実行」を選択する。

REM CMake をシステム領域にインストール
winget install --scope machine --id Kitware.CMake -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/qn /norestart ADD_CMAKE_TO_PATH=System"

SuiteSparse,Metis のインストール(ソースコードを用いたインストール)(Windows 上)

次のページに記載の手順を行う.

https://github.com/jlblancoc/suitesparse-metis-for-windows

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

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

  1. 以下の操作を管理者権限コマンドプロンプトで実行する (手順:Windowsキーまたはスタートメニュー → cmd と入力 → 右クリック → 「管理者として実行」)。

  2. SuiteSparse の作業ディレクトリを削除する(以前作業したときのものが残っていたら削除したいため)
    c:
    cd c:\
    rmdir /s /q suitesparse-metis-for-windows
    
  3. ソースコードをダウンロード,環境変数 SP_ROOTにダウンロードしたディレクトリを設定
    cd c:\
    git clone --recursive https://github.com/jlblancoc/suitesparse-metis-for-windows
    powershell -command "[System.Environment]::SetEnvironmentVariable(\"SP_ROOT\", \"c:\suitesparse-metis-for-windows\", \"Machine\")"
    
  4. cmake の実行

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

    cd c:\
    cd suitesparse-metis-for-windows
    rmdir /s /q build
    mkdir build
    cd build
    del CMakeCache.txt
    rmdir /s /q CMakeFiles
    cmake .. -A x64 -T host=x64 ^
        -DBUILD_SHARED_LIBS=ON ^
         -DCMAKE_INSTALL_PREFIX="C:/suitesparse"
    
  5. 実行結果の確認

    エラーメッセージが出ていないこと.

  6. インストールの実行
    cmake --build . --config Release --target INSTALL -- /m:4
    
  7. 実行結果の確認
  8. Windowsシステム環境変数 Pathに,次を追加することにより,パスを通す
    • C:\suitesparse\lib\lapack_blas_windows
    • C:\suitesparse\lib
    • C:\suitesparse\bin

    Windows で,管理者権限コマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー > cmd と入力 > 右クリック > 「管理者として実行」)。

    次のコマンドを実行

    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\suitesparse\lib\lapack_blas_windows\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\suitesparse\lib\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\suitesparse\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
  9. Windowsシステム環境変数 SUITESPARSE_ROOT に,c:\suitesparse を設定

    Windows で,管理者権限コマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー > cmd と入力 > 右クリック > 「管理者として実行」)。

    次のコマンドを実行

    powershell -command "[System.Environment]::SetEnvironmentVariable(\"SUITESPARSE_ROOT\", \"c:\suitesparse\", \"Machine\")"
    
  10. Windowsシステム環境変数 METIS_ROOT に,c:\suitesparse を設定

    Windows で,管理者権限コマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー > cmd と入力 > 右クリック > 「管理者として実行」)。

    次のコマンドを実行

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