Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Kompilieren für Windows
Siehe auch
Diese Seite beschreibt, wie man den Windows-Editor und Exportvorlagen-Binärdateien aus dem Quellcode kompiliert. Wenn Sie Ihr Projekt stattdessen nach Windows exportieren wollen, lesen Sie Exportieren für Windows.
Anforderungen
Zum Kompilieren unter Windows ist Folgendes erforderlich:
A C++ compiler. Use one of the following:
Visual Studio Community, version 2019 or later. Visual Studio 2022 is recommended. During installation make sure to select C++ in the list of workflows, and select the following individual components:
MSVC v142 - VS 2019 C++ {arch} build tools (Latest) for the target architectures.
Windows 11 SDK (10.0.22621.0) (exact version).
MSVC v143 - VS 2022 C++ {arch} build tools (Latest) for the target architectures.
Windows 11 SDK (10.0.22621.0) or newer.
MSVC Build Tools for {arch} (Latest) for the target architectures.
Windows 11 SDK (10.0.22621.0) or newer.
If you've already installed Visual Studio without C++ support for the target architecture, or without the Windows SDK, run the installer again; it should present you a Modify button. Supports
x86_64,x86_32, andarm64.MinGW-w64 with GCC can be used as an alternative to Visual Studio. Be sure to install/configure it to use the
posixthread model. Important: When using MinGW to compile themasterbranch, you need GCC 12 or later. Supportsx86_64andx86_32only.MinGW-LLVM with clang can be used as an alternative to Visual Studio and MinGW-w64. Important: When using MinGW to compile the
masterbranch, you need clang 14 or later. Supportsx86_64,x86_32, andarm64.
Python 3.9+. Make sure to enable the option to add Python to the
PATHin the installer.SCons 4.4+ build system. Using the latest release is recommended, especially for proper support of recent Visual Studio releases.
Direct3D 12 dependencies (can be skipped with the
d3d12=noSCons option if Direct3D 12 support is not desired).
Bemerkung
If you have Scoop installed, you can easily install MinGW and other dependencies using the following command:
scoop install python mingw
Scons will still need to be installed via pip
Bemerkung
If you have MSYS2 installed, you can easily install MinGW and other dependencies using the following command:
pacman -S mingw-w64-x86_64-gcc mingw-w64-i686-gcc make python-pip
Für jedes MSYS2 MinGW-Subsystem sollten Sie dann pip3 install scons in seiner Shell ausführen.
Siehe auch
Um den Godot-Quellcode zum Kompilieren zu erhalten, siehe Beschaffung des Quellcodes.
Eine allgemeine Übersicht über die Verwendung von SCons für Godot finden Sie unter Einführung in das Buildsystem.
SCons einrichten
To install SCons, open the command prompt and run the following command:
python -m pip install scons
Wenn Sie die Meldung Defaulting to user installation because normal site-packages is not writeable erhalten, müssen Sie den Befehl möglicherweise mit erweiterten Rechten erneut ausführen. Öffnen Sie eine neue Eingabeaufforderung als Administrator und führen Sie den Befehl erneut aus, um sicherzustellen, dass SCons im PATH verfügbar ist.
Um zu überprüfen, ob Sie Python und SCons korrekt installiert haben, können Sie python --version und scons --version in eine Eingabeaufforderung (cmd.exe) eingeben.
Wenn die obigen Befehle nicht funktionieren, stellen Sie sicher, dass Sie Python nach der Installation zu Ihrer PATH-Umgebungsvariablen hinzufügen und überprüfen Sie es dann erneut. Sie können dies tun, indem Sie das Python-Installationsprogramm erneut ausführen und die Option zum Hinzufügen von Python zum PATH aktivieren.
Wenn SCons Ihre Visual Studio-Installation nicht erkennen kann, könnte es sein, dass Ihre SCons-Version zu alt ist. Aktualisieren Sie es auf die neueste Version mit python -m pip install --upgrade scons.
Den Godot-Quellcode herunterladen
Siehe Beschaffung des Quellcodes für detaillierte Anweisungen.
Das Tutorial geht davon aus, dass Sie den Quellcode in C:\godot abgelegt haben.
Warnung
Um Verlangsamungen durch ständiges Virenscannen während der Kompilierung zu vermeiden, fügen Sie den Godot-Quellcode-Ordner zur Liste der Ausnahmen in Ihrer Antiviren-Software hinzu.
Für Windows Defender drücken Sie die Windows-Taste, geben "Windows Sicherheit" ein und drücken dann Enter. Klicken Sie unter Viren- und Bedrohungsschutz auf Einstellungen verwalten und scrollen Sie nach unten zu Ausnahmen. Klicken Sie auf Ausnahmen hinzufügen oder entfernen und fügen Sie den Godot-Quellcode-Ordner hinzu.
Kompilieren
Einen Compiler auswählen
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-w64, 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. If you are using MinGW-LLVM, pass both
use_mingw=yes and use_llvm=yes to the SCons command line.
Tipp
Während der Entwicklung ist die Verwendung des Visual Studio-Compilers in der Regel die bessere Idee, da er die Godot-Binärdatei viel schneller als MinGW linkt. Allerdings kann MinGW mit Hilfe der Link-Time-Optimierung (siehe unten) optimiertere Binärdateien erzeugen, so dass es für den Produktiveinsatz die bessere Wahl ist. Dies gilt insbesondere für die GDScript-VM, die mit MinGW viel besser funktioniert als mit MSVC. Daher ist es empfehlenswert, MinGW für die Erstellung von Builds zu verwenden, die Sie an Spieler verteilen.
Alle offiziellen Godot-Binärdateien werden in benutzerdefinierten Containern unter Verwendung von MinGW gebaut.
SCons starten
Nachdem Sie eine Eingabeaufforderung geöffnet haben, wechseln Sie in das Stammverzeichnis des Quellcodes der Engine (mit cd) und geben Sie ein:
C:\godot> scons platform=windows
Bemerkung
Beim Kompilieren mit mehreren CPU-Threads kann SCons eine Warnung über das Fehlen von pywin32 ausgeben. Sie können diese Warnung getrost ignorieren.
Tipp
If you are compiling Godot to make changes or contribute to the engine,
you may want to use the SCons options dev_build=yes or dev_mode=yes.
See Aliasnamen für Entwicklung und Produktion
for more info.
If all goes well, the resulting binary executable will be placed in
C:\godot\bin\ with the name godot.windows.editor.x86_32.exe or
godot.windows.editor.x86_64.exe. By default, SCons will build a binary matching
your CPU architecture, but this can be overridden using arch=x86_64,
arch=x86_32, or arch=arm64.
Diese ausführbare Datei enthält die gesamte Engine und läuft ohne jegliche Abhängigkeiten. Wenn Sie sie ausführen, wird der Projektmanager angezeigt.
Tipp
Wenn Sie Godot für den Produktivseinsatz kompilieren, können Sie die endgültige ausführbare Datei kleiner und schneller machen, indem Sie die SCons-Option production=yes hinzufügen. Dies ermöglicht zusätzliche Compiler-Optimierungen und Link-Time-Optimierungen.
LTO takes some time to run and requires up to 30 GB of available RAM
while compiling (depending on toolchain). If you're running out of memory
with the above option, use production=yes lto=none or production=yes lto=thin
(LLVM only) for a lightweight but less effective form of LTO.
Bemerkung
Wenn Sie getrennte Editoreinstellungen für Ihre eigenen Godot-Builds und die offiziellen Releases verwenden wollen, können Sie den Portabler Modus aktivieren, indem Sie eine Datei namens ._sc_ oder _sc_ im bin/-Ordner anlegen.
Installing Direct3D 12 requirements
By default, Windows builds of Godot contain support for the Direct3D 12 graphics
API. Compiling with Direct3D 12 support requires additional dependencies
to be installed. If you wish to skip this step, you can use the d3d12=no
SCons option; Vulkan and OpenGL support will remain available if you do so.
You can install the required dependencies by running
python misc/scripts/install_d3d12_sdk_windows.py
in the Godot source repository. After running this script, compile Godot as usual.
This will use the default paths for the various dependencies, which match the
ones used in the script.
You can find the detailed steps below if you wish to set up dependencies manually, but the above script handles everything for you (including the optional PIX and Agility SDK components).
godot-nir-static library. Wir kompilieren die Mesa-Bibliotheken, die Sie benötigen, in eine statische Bibliothek. Laden Sie ihn irgendwo hin herunter, entpacken Sie ihn und merken Sie sich den Pfad zum entpackten Ordner, Sie werden ihn weiter unten benötigen.
Bemerkung
Optional können Sie die godot-nir-static-Bibliotheken mit den folgenden Schritten selbst erstellen:
Installieren Sie das Python-Paket mako, das zur Erzeugung einiger Dateien benötigt wird.
Klonen Sie das Verzeichnis godot-nir-static und navigieren Sie zu diesem Verzeichnis.
Run the following:
git submodule update --init
./update_mesa.sh
scons
If you are building with MinGW-w64, add use_mingw=yes to the scons
command, you can also specify the build architecture using arch={architecture}.
If you are building with MinGW-LLVM, add both use_mingw=yes and
use_llvm=yes to the scons command.
If you are building with MinGW and the binaries are not located in
the PATH, add mingw_prefix="/path/to/mingw" to the scons
command.
The Mesa static library should be built using the same compiler and the same CRT (if you are building with MinGW) you are using for building Godot.
Optional können Sie mit den folgenden Optionen kompilieren, um zusätzliche Funktionen zu erhalten:
PIX ist eine Anwendung zur Performanceoptimierung und Fehlersuche für Direct3D12-Anwendungen. Wenn Sie die Unterstützung dafür einkompilieren, können Sie über PIX viel detailliertere Informationen erhalten, die Ihnen bei der Optimierung Ihres Spiels und der Behebung von Grafikfehlern helfen. Um es zu verwenden, laden Sie das WinPixEventRuntime-Paket herunter. Sie werden zu einer NuGet-Paketseite weitergeleitet, wo Sie auf "Paket herunterladen" klicken können, um es zu erhalten. Nach dem Herunterladen ändern Sie die Dateierweiterung in .zip und entpacken die Datei in einen beliebigen Pfad.
Agility SDK kann verwendet werden, um Zugang zu den neuesten Direct3D 12-Funktionen zu erhalten, ohne auf Treiber-Updates angewiesen zu sein. Um es zu verwenden, laden Sie das neueste Agility SDK-Paket herunter. Sie werden zu einer NuGet-Paketseite weitergeleitet, wo Sie auf "Paket herunterladen" klicken können, um es zu erhalten. Nach dem Herunterladen ändern Sie die Dateierweiterung in .zip und entpacken die Datei in einen beliebigen Pfad.
Bemerkung
Wenn Sie eine Vorabversion des Agility-SDK verwenden, denken Sie daran, den Entwicklermodus in Windows zu aktivieren, da er sonst nicht genutzt werden kann.
Bemerkung
If you want to use a PIX with MinGW build, navigate to PIX runtime directory and use the following commands to generate import library:
# For x86-64:
gendef ./bin/x64/WinPixEventRuntime.dll
dlltool --machine i386:x86-64 --no-leading-underscore -d WinPixEventRuntime.def -D WinPixEventRuntime.dll -l ./bin/x64/libWinPixEventRuntime.a
# For ARM64:
gendef ./bin/ARM64/WinPixEventRuntime.dll
dlltool --machine arm64 --no-leading-underscore -d WinPixEventRuntime.def -D WinPixEventRuntime.dll -l ./bin/ARM64/libWinPixEventRuntime.a
When building Godot, you will need to tell SCons where to look for the additional libraries:
C:\godot> scons platform=windows mesa_libs=<...>
Oder, wenn alle Optionen aktiviert sind:
C:\godot> scons platform=windows mesa_libs=<...> agility_sdk_path=<...> pix_path=<...>
Bemerkung
PIX support is disabled by default, even if you have it installed.
To enable it, pass use_pix=yes to SCons.
Bemerkung
For the Agility SDK's DLLs, you have to explicitly choose the kind of
workflow. Single-arch is the default (DLLs copied to bin/). If you pass
agility_sdk_multi_arch=yes to SCons, you'll opt-in for multi-arch.
DLLs will be copied to the appropriate bin/<arch>/ subdirectories
and at runtime, the right one will be loaded.
Compiling with AccessKit support
AccessKit provides support for screen readers.
Compiling with AccessKit requires additional dependencies to be installed.
If you wish to skip this step, you can use the accesskit=no SCons option.
You can install the required dependencies by running
python misc/scripts/install_accesskit.py
in the Godot source repository. After running this script, compile Godot as usual.
Bemerkung
You can optionally build the AccessKit libraries yourself with the following steps:
Clone the godot-accesskit-c-static directory and navigate to it.
Run the following command:
cd accesskit-c
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
The AccessKit static library should be built using the same compiler and the same CRT (if you are building with MinGW) you are using for building Godot.
To compile Godot with a custom build of AccessKit, add accesskit_sdk_path={path} to
tell SCons where to look for the AccessKit libraries:
scons platform=windows accesskit_sdk_path=<...>
Compiling with WinRT support
WinRT provides support for OneCore TTS (accessing Windows 10+ voices), HDR color information monitoring, and emoji picker.
If you are building with MinGW, compiling with WinRT requires additional dependencies to be installed.
If you wish to skip this step, you can use the winrt=no SCons option.
You can install the required dependencies by running
python misc/scripts/install_winrt.py
in the Godot source repository. After running this script, compile Godot as usual.
Bemerkung
You can optionally build the WinRT headers yourself with the following steps:
Clone the winrt-mingw directory and navigate to it.
Run the following command:
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCPPWINRT_BUILD_VERSION=2.0.250303.1 -DBUILD_TESTING=OFF cppwinrt/
echo "" > build/app.manifest.rc
cmake --build build
./build/cppwinrt.exe -input windows-rs/crates/libs/bindgen/default/ -output include/
To compile Godot with a custom build of WinRT, add winrt_path={path} to
tell SCons where to look for the AccessKit headers:
scons platform=windows winrt_path=<...>
Kompilieren mit ANGLE-Unterstützung
ANGLE bietet eine Übersetzungsschicht von OpenGL ES 3.x zu Direct3D 11 und kann verwendet werden, um die Unterstützung für den Kompatibilitäts-Renderer auf einigen älteren GPUs mit veralteten OpenGL-Treibern und auf Windows für ARM zu verbessern.
Compiling with ANGLE requires additional dependencies to be installed.
If you wish to skip this step, you can use the angle=no SCons option.
You can install the required dependencies by running
python misc/scripts/install_angle.py
in the Godot source repository. After running this script, compile Godot as usual.
Bemerkung
Optional können Sie die godot-angle-static-Bibliotheken mit den folgenden Schritten selbst erstellen:
Klonen Sie das Verzeichnis godot-angle-static und navigieren Sie zu diesem Verzeichnis.
Run the following command:
git submodule update --init
./update_angle.sh
scons
If you are buildng with MinGW, add use_mingw=yes to the command,
you can also specify the build architecture using arch={architecture}.
If you are building with MinGW-LLVM, add both use_mingw=yes and
use_llvm=yes to the scons command.
If you are building with MinGW and the binaries are not located in
the PATH, add mingw_prefix="/path/to/mingw" to the scons
command.
The ANGLE static library should be built using the same compiler and the same CRT (if you are building with MinGW) you are using for building Godot.
To compile Godot with a custom build of ANGLE, add angle_libs={path} to
tell SCons where to look for the ANGLE libraries:
scons platform=windows angle_libs=<...>
Entwickeln in Visual Studio
Die Verwendung einer IDE ist für die Kompilierung von Godot nicht erforderlich, da SCons sich um alles kümmert. Wenn Sie jedoch beabsichtigen, den C++-Code der Engine zu weiterzuentwickeln oder zu debuggen, sind Sie möglicherweise an der Konfiguration eines Code-Editors oder einer IDE interessiert.
Ordnerbasierte Editoren erfordern keine besondere Einrichtung, um mit der Codebasis von Godot zu arbeiten. Um Projekte mit Visual Studio zu bearbeiten, müssen sie als Solution eingerichtet werden.
You can create a Visual Studio solution via SCons by running SCons with
the vsproj=yes parameter, like this:
scons platform=windows vsproj=yes
Sie können jetzt den Quellcode von Godot in einer Visual Studio-Solution öffnen und Godot mit dem Build-Button von Visual Studio bauen.
Siehe auch
Siehe Visual Studio für weitere Details.
Fehlersuche
If you get a compilation failure when using MSVC, make sure to apply the latest updates. You can do so by starting the Visual Studio IDE and using , then in the menu bar at the top. Install all updates, then try compiling again.
Cross-Kompilierung für Windows von anderen Betriebssystemen
If you are a Linux or macOS user, you need to install MinGW-w64, which typically comes in 32-bit and 64-bit variants, or MinGW-LLVM, which comes as a single archive for all target architectures. The package names may differ based on your distribution, here are some known ones:
Arch Linux |
pacman -S mingw-w64
|
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
|
Before attempting the compilation, SCons will check for
the following binaries in your PATH environment variable:
# for MinGW-w64
i686-w64-mingw32-gcc
x86_64-w64-mingw32-gcc
# for MinGW-LLVM
aarch64-w64-mingw32-clang
i686-w64-mingw32-clang
x86_64-w64-mingw32-clang
If the binaries are not located in the PATH (e.g. /usr/bin),
you can define the following environment variable to give a hint to
the build system:
export MINGW_PREFIX="/path/to/mingw"
Dabei ist /path/to/mingw der Pfad, der das bin-Verzeichnis enthält, in dem sich i686-w64-mingw32-gcc und x86_64-w64-mingw32-gcc befinden (z.B. /opt/mingw-w64, wenn sich die Binaries in /opt/mingw-w64/bin befinden).
To make sure you are doing things correctly, executing the following in the shell should result in a working compiler (the version output may differ based on your system):
${MINGW_PREFIX}/bin/x86_64-w64-mingw32-gcc --version
# x86_64-w64-mingw32-gcc (GCC) 13.2.0
Bemerkung
If you are building with MinGW-LLVM, add use_llvm=yes to the scons command.
Bemerkung
When cross-compiling for Windows using MinGW-w64, keep in mind only
x86_64 and x86_32 architectures are supported. MinGW-LLVM supports
arm64 as well. Be sure to specify the right arch= option when
invoking SCons if building from a different architecture.
Fehlersuche
Das Cross-Compiling von einigen Ubuntu-Versionen kann zu diesem Bug führen, da die Standardkonfiguration keine Unterstützung für POSIX-Threading bietet.
You can change that configuration following those instructions, for 64-bit:
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>
And for 32-bit:
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>
Erstellen von Windows-Exportvorlagen
Windows-Exportvorlagen werden durch Kompilieren von Godot ohne Editor und mit den folgenden Flags erstellt:
C:\godot> scons platform=windows target=template_debug arch=x86_32
C:\godot> scons platform=windows target=template_release arch=x86_32
C:\godot> scons platform=windows target=template_debug arch=x86_64
C:\godot> scons platform=windows target=template_release arch=x86_64
C:\godot> scons platform=windows target=template_debug arch=arm64
C:\godot> scons platform=windows target=template_release arch=arm64
Wenn Sie vorhaben, die Standard-Exportvorlagen zu ersetzen, kopieren Sie diese an den folgenden Ort, wobei Sie <Version> durch die Versionskennung ersetzen (wie 4.2.1.stable oder 4.3.dev):
%APPDATA%\Godot\export_templates\<version>\
With the following names:
windows_debug_x86_32_console.exe
windows_debug_x86_32.exe
windows_debug_x86_64_console.exe
windows_debug_x86_64.exe
windows_debug_arm64_console.exe
windows_debug_arm64.exe
windows_release_x86_32_console.exe
windows_release_x86_32.exe
windows_release_x86_64_console.exe
windows_release_x86_64.exe
windows_release_arm64_console.exe
windows_release_arm64.exe
However, if you are using custom modules or custom engine code, you may instead want to configure your binaries as custom export templates in the project export menu. You must have Advanced Options enabled to set this.
Sie brauchen sie in diesem Fall nicht zu kopieren, sondern referenzieren einfach die resultierenden Dateien im Verzeichnis bin\ Ihres Godot-Quellordners, so dass Sie beim nächsten Build automatisch die benutzerdefinierten Vorlagen referenziert haben.