Windows用のコンパイル¶
参考
This page describes how to compile Windows editor and export template binaries from source. If you're looking to export your project to Windows instead, read Exporting for Windows.
必要条件¶
Windowsでコンパイルするには、次のことが必要です:
Visual Studio Community, version 2017 or later. VS 2019 is recommended. Make sure to read "Installing Visual Studio caveats" below or you will have to run/download the installer again.
MinGW-w64 with GCC can be used as an alternative to Visual Studio. Be sure to install/configure it to use the
posix
thread model.Python 3.5+. Make sure to enable the option to add Python to the ``PATH`` in the installer.
SCons build system. Using the latest release is recommended, especially for proper support of recent Visual Studio releases.
注釈
もし MSYS2 がインストールされていれば、MinGWや他の依存関係を、次のコマンドで簡単にインストールできます:
pacman -S mingw-w64-x86_64-python3-pip mingw-w64-x86_64-gcc \
mingw-w64-i686-python3-pip mingw-w64-i686-gcc make
For each MSYS2 MinGW subsystem, you should then run pip3 install scons in its shell.
参考
To get the Godot source code for compiling, see ソースの取得.
Godotにおける基本的なSconsの使い方については、ビルドシステムの説明を参照してください。
SConsの設定¶
To install SCons, open the command prompt and run the following command:
python -m pip install scons
If you are prompted with the message
Defaulting to user installation because normal site-packages is not
writeable
, you may have to run that command again using elevated
permissions. Open a new command prompt as an Administrator then run the command
again to ensure that SCons is available from the PATH
.
PythonとSConsがきちんとインストールされたかどうか確認するには、コマンドプロンプト (cmd.exe
) にてpython --version
およびscons --version
とタイプしてみてください。
上記のコマンドが失敗した場合は、インストール後にPythonを環境変数PATH
に含めてから、ふたたび確認してください。そうするには、Pythonインストーラーを再実行して、PythonをPATH
に含めるオプションを有効にすればできます。
If SCons cannot detect your Visual Studio installation, it might be that your
SCons version is too old. Update it to the latest version with
python -m pip install --upgrade scons
.
Visual Studioのインストールに関する注意事項¶
Visual Studio 2017あるいは2019をインストールする場合は、ワークロードのリストから C++ を有効しなければなりません。
Visual Studio 2015をインストールする場合は、標準ではなくカスタムを選択し、言語から C++ を選んでください。
もし間違ってC++サポート無しでVisual Studioをインストールしてしまったなら、ふたたびインストーラーを実行してください。変更 (Modify)ボタンが表示されるはずです。プログラムの追加と削除 からインストーラーを起動しても、修復オプションしか表示されず、C++ツールはインストールできません。
Godotのソースをダウンロードする¶
Refer to ソースの取得 for detailed instructions.
ここからのチュートリアルは、ソースコードをC:\godot
に置いたとして進めます。
警告
To prevent slowdowns caused by continuous virus scanning during compilation, add the Godot source folder to the list of exceptions in your antivirus software.
For Windows Defender, hit the Windows key, type "Windows Defender Settings" then hit Enter. Under Virus & threat protection, go to Virus & threat protection setting and scroll down to Exclusions. Click Add or remove exclusions then add the Godot source folder.
コンパイル¶
コンパイラの選択¶
SCons will automatically find and use an existing Visual Studio installation.
If you do not have Visual Studio installed, it will attempt to use
MinGW instead. If you already have Visual Studio installed and want to
use MinGW, pass use_mingw=yes
to the SCons command line. Note that MSVC
builds cannot be performed from the MSYS2 or MinGW shells. Use either
cmd.exe
or PowerShell instead.
開発版には、MinGWよりも早くGodotバイナリをリンクできるVisual Studioのほうが、通常は好ましいでしょう。しかし、MinGWはリンク時最適化を用いることにより、さらに最適化されたバイナリを出力できるので (下記を参照)、製品版ではより良い選択肢になるでしょう。
SConsの実行¶
コマンド プロンプトを開き、エンジンのソースコードがあるディレクトリのルートに移動して (cd
を使用)、次のように打ちます:
C:\godot> scons platform=windows
ビルド速度を上げるためにCPUスレッド数を指定できます:
C:\godot> scons -j6 platform=windows
In general, it is OK to have at least as many threads compiling Godot as you
have cores in your CPU, if not one or two more. Feel free to add the -j
option to any SCons command you see below.
注釈
複数CPUスレッドでコンパイルするとき、pywin32が無いという警告をSConsは出すかもしれません。しかし、これは無視しても大丈夫です。
If all goes well, the resulting binary executable will be placed in
C:\godot\bin\
with the name godot.windows.tools.32.exe
or
godot.windows.tools.64.exe
. By default, SCons will build a binary matching
your CPU architecture, but this can be overridden using bits=64
or
bits=32
.
この実行ファイルにはエンジン全体が含まれていて、単体で起動できます。実行すると、プロジェクト マネージャーが現れます。
注釈
制作に使うGodotをコンパイルするなら、SConsのオプション target=release_debug
を追加すれば、より小さくて高速な実行ファイルにすることができます。
If you are compiling Godot with MinGW, you can make the binary
even smaller and faster by adding the SCons option use_lto=yes
.
As link-time optimization is a memory-intensive process,
this will require about 7 GB of available RAM while compiling.
注釈
If you want to use separate editor settings for your own Godot builds
and official releases, you can enable
自己完結型モード by creating a file called
._sc_
or _sc_
in the bin/
folder.
Development in Visual Studio¶
Using an IDE is not required to compile Godot, as SCons takes care of everything. But if you intend to do engine development or debugging of the engine's C++ code, you may be interested in configuring a code editor or an IDE.
Folder-based editors don't require any particular setup to start working with Godot's codebase. To edit projects with Visual Studio they need to be set up as a solution.
SConsを vsproj=yes
パラメータとともに実行すれば、Visual Studioソリューションを生成できます:
scons p=windows vsproj=yes
これでGodotのソースをVisual Studioのソリューションとして開けるようになり、Visual Studioのビルド (Build)ボタンでビルドできます。
参考
See Visual Studio for further details.
他のオペレーティングシステムからのWindowsのクロスコンパイル¶
If you are a Linux or macOS user, you need to install MinGW-w64, which typically comes in 32-bit and 64-bit variants. The package names may differ based on your distribution, here are some known ones:
Arch Linux |
Install mingw-w64-gcc from the AUR (AURからmingw-w64-gccをインストール)。 |
Debian / Ubuntu |
apt install mingw-w64
|
Fedora |
dnf install mingw64-gcc-c++ mingw64-winpthreads-static \
mingw32-gcc-c++ mingw32-winpthreads-static
|
macOS |
brew install mingw-w64
|
Mageia |
urpmi mingw64-gcc-c++ mingw64-winpthreads-static \
mingw32-gcc-c++ mingw32-winpthreads-static
|
コンパイルする前に、SConsは下記のバイナリが PATH
環境変数にあるかチェックします:
i686-w64-mingw32-gcc
x86_64-w64-mingw32-gcc
もしバイナリが PATH``(たとえば ``/usr/bin
)になかった場合、このように環境変数を設定することでビルドシステムに教えられます:
export MINGW32_PREFIX="/path/to/i686-w64-mingw32-"
export MINGW64_PREFIX="/path/to/x86_64-w64-mingw32-"
正しく設定できたか確認するには、下記のシェルを実行することで動くコンパイラが呼ばれるはずです (バージョン表示はシステムにより異なります):
${MINGW32_PREFIX}gcc --version
# i686-w64-mingw32-gcc (GCC) 6.1.0 20160427 (Mageia MinGW 6.1.0-1.mga6)
トラブルシューティング¶
Ubuntuのいくつかのバージョンでは、標準設定でPOSIXスレッディングが有効になっていないので、クロスコンパイルするとこのバグ (英語) が発生する可能性があります。
下記のとおりにすれば設定を変更できます。64ビットの場合 (それぞれ実行してから、リストにある x86_64-w64-mingw32-gcc-posix および x86_64-w64-mingw32-g++-posix を選択する):
sudo update-alternatives --config x86_64-w64-mingw32-gcc
<choose x86_64-w64-mingw32-gcc-posix from the list>
sudo update-alternatives --config x86_64-w64-mingw32-g++
<choose x86_64-w64-mingw32-g++-posix from the list>
そして32ビットの場合 (それぞれ実行してから、リストにある i686-w64-mingw32-gcc-posix および i686-w64-mingw32-g++-posix を選択する):
sudo update-alternatives --config i686-w64-mingw32-gcc
<choose i686-w64-mingw32-gcc-posix from the list>
sudo update-alternatives --config i686-w64-mingw32-g++
<choose i686-w64-mingw32-g++-posix from the list>
Windowsエクスポートテンプレートの作成¶
Windowsのエクスポート テンプレートは、Godotをエディタ無しでコンパイルすることで作成します。次のフラグを使用してください:
C:\godot> scons platform=windows tools=no target=release_debug bits=32
C:\godot> scons platform=windows tools=no target=release bits=32
C:\godot> scons platform=windows tools=no target=release_debug bits=64
C:\godot> scons platform=windows tools=no target=release bits=64
もし標準のエクスポート テンプレートを置き換えるつもりであるなら、それらを下記の場所にコピーしてください。<version>
の部分はバージョン識別子で置き換えます (3.1.1.stable
や 3.2.dev
のように):
%USERPROFILE%\AppData\Roaming\Godot\templates\<version>\
名前は次のようにします:
windows_32_debug.exe
windows_32_release.exe
windows_64_debug.exe
windows_64_release.exe
一方、もしカスタム モジュールやカスタム エンジンコードを使用しているなら、バイナリをカスタムのエクスポート テンプレートとして指定することもできます。

この場合はコピーする必要はなく、Godotのソースフォルダ内にある bin\
ディレクトリに出力されたファイルを指定するだけです。こうすれば、次にビルドした時も、自動的にカスタム テンプレートを参照するようになります。