金子邦彦研究室3次元,地図Windows でのインストールと動作確認(3次元,地図関係)Blender のインストール(ソースコード,Build Tools for Visual Studio を使用を使用)(Windows 上)

Blender のインストール(ソースコード,Build Tools for Visual Studio を使用を使用)(Windows 上)

Windows で,Blender 最新版をソースコードからビルドして,インストールする.

https://wiki.blender.org/wiki/Building_Blender/Windowsの手順に従う

Blender のインストールは,複数の方法がある.

Blenderは,3次元コンピュータグラフィックス・アニメーションソフトウェア. 3次元モデルの編集,レンダリング、光源やカメラ等を設定しての3次元コンピュータグラフィックス・アニメーション作成機能がある.

目次

サイト内の関連ページ

前準備

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

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

サイト内の関連ページ

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

関連する外部ページ

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

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

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

サイト内の関連ページ

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

関連する外部ページ

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

7-Zip のインストール(Windows 上)

7-Zip 23.01 のインストール

7-Zipは,ファイルの圧縮や展開のツール.さまざまなフォーマットに対応している.

Windows では, コマンドプロンプトを管理者として開き, 次のコマンドを実行することにより, 7-Zip 23.01 のインストールを行うことができる.

mkdir %HOMEPATH%\7zip
cd %HOMEPATH%\7zip
curl -O https://www.7-zip.org/a/7z2301-x64.exe
.\7z2301-x64.exe
powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\7-Zip\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"

サイト内の関連ページ

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

関連する外部ページ

7-Zip の公式ページ: https://sevenzip.osdn.jp/

Subversion for Windows (SlikSVN) のインストール

Subversion for Windows (SlikSVN) のインストール: 別ページ »で説明

Subversion for Windows (SlikSVN) のページ: https://sliksvn.com/

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

サイト内の関連ページ

関連する外部ページ

Python の公式ページ: https://www.python.org/

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 のインストールと動作確認: 別ページ »で説明している.

関連する外部ページ

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

次の公式ページの手順による

https://wiki.blender.org/wiki/Building_Blender/Windows

  1. タグの確認

    インストールしたい Blender のバージョンにあうタグを,次のページで探す.

    https://github.com/blender/blender/tags

  2. Visual Studio の x64 Native Tools コマンドプロンプトを開く.

    起動は,Windows のメニューで「Visual Studio 20..」の下の「x64 Native Tools コマンドプロンプト (x64 Native Tools Command Prompt)」を選ぶ.「x64」は,64ビット版の意味である.

    「x64 Native Tools コマンドプロンプト (x64 Native Tools Command Prompt)」がないとき:

    C++ ビルドツール (Build Tools) のインストールを行うことで, 「x64 Native Tools コマンドプロンプト (x64 Native Tools Command Prompt)」がインストールされる.その手順は,別ページ »で説明

  3. Blender のソースコードをダウンロード

    master」のところには,使用したいバージョンの Blender のブランチを指定する.

    cd %HOMEPATH%
    rmdir /s /q blender
    git clone -b master --recursive https://github.com/blender/blender
    

    [image]
  4. make help を実行し、make のオプションを確認

    Blender のソースコードに付属の make.bat を使用している.

    cd %HOMEPATH%
    cd blender
    make help
    

    [image]
  5. Blender のコンパイル済みのライブラリをダウンロード

    2022b」のところは, さきほど make help を実行したときの表示を参考に,必要に応じて変更する.

    Visual Studio Community 2022 を使うときは「make update 2022b」ではなく,「make update 2022」 を実行.

    cd %HOMEPATH%
    cd blender
    make update 2022b
    

    [image]
    (以下省略)

    「Would you like to download them?」と表示されたときは「y」を入れる.

    [image]

    終了まで時間がかかるので,しばらく待つ

    ダウンロード終了を確認する.

  6. 終了の確認

    [image]
  7. ソースコードからビルドする

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

    公式ページの手順に従うが,公式ページの手順通りに実行するとエラーが出たので, 手順を変えている.

    終了まで時間がかかるので,しばらく待つ

    cd %HOMEPATH%
    cd blender
    del CMakeCache.txt
    rmdir /s /q CMakeFiles
    cd %HOMEPATH%
    rmdir /s /q blender-build
    mkdir blender-build
    cd blender-build
    cmake ..\blender -G "Visual Studio 17 2022" -A x64 -T host=x64 ^
        -DCMAKE_INSTALL_PREFIX="c:\blender"
    cmake --build . --config RELEASE 
    cmake --build . --config RELEASE --target INSTALL -- /m:4 
    
  8. 実行結果の確認

    [image]
  9. 確認のため Blender を起動してみる
    c:\blender\blender.exe
    

    [image]
  10. Blender の画面が開くので確認する

    [image]

Blender の Python モジュールのインストール

次のページの記載による: https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule

  1. Blender の Python モジュールのビルド
    cd %HOMEPATH%
    cd blender
    del CMakeCache.txt
    rmdir /s /q CMakeFiles
    cd %HOMEPATH%
    rmdir /s /q blender-build
    mkdir blender-build
    cd blender-build
    cmake ..\blender -G "Visual Studio 17 2022" -A x64 -T host=x64 ^
        -DCMAKE_INSTALL_PREFIX="c:\blender" ^
        -DWITH_PYTHON_INSTALL=OFF -DWITH_AUDASPACE=OFF -DWITH_PYTHON_MODULE=ON ^
        -DWITH_WINDOWS_BUNDLE_CRT=OFF
    cmake --build . --config RELEASE 
    cmake --build . --config RELEASE --target INSTALL -- /m:4
    xcopy /E c:\blender\bpy "C:\Program Files\Python310\Lib\site-packages\bpy"
    
  2. 終了の確認

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

    [image]
  3. インストールできたかの確認(書きかけ.うまく動作しません.申し訳ございません)

    コマンドプロンプトで次のコマンドを実行する.

    エラーメッセージが出なければ OK.

    python -c "import bpy; scene = bpy.data.scenes['Scene']; print(scene)"
    

    [image]