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.

Compilation pour Windows

Voir aussi

Cette page explique comment compiler l’éditeur Windows et exporter les binaires de modèle d'export depuis le code source. Si vous chercher à exporter votre projet vers Windows, voyez plutôt Exportation pour Windows.

Pré-requis

Pour la compilation sous Windows, ce qui suit est nécessaire :

  • A C++ compiler. Use one of the following:

    • Visual Studio Community, version 2019 or later. Visual Studio 2022 is recommended. Make sure to enable C++ in the list of workflows to install. Make sure to enable Windows SDK 10.0.22621 (for Visual Studio 2019) or more recent version (for Visual Studio 2022+). If you've already installed Visual Studio without C++ support, run the installer again; it should present you a Modify button. Supports x86_64, x86_32, and arm64.

    • MinGW-w64 avec GCC peut être utilisé comme une alternative à Visual Studio. Assurez-vous de l'installer/configurer pour utiliser le modèle de thread posix. Important : Lors de l'utilisation de MinGW pour compiler la branche master, vous aurez besoin de GCC 9 ou plus. Support de x86_64 et x86_32 seulement.

    • MinGW-LLVM with clang can be used as an alternative to Visual Studio and MinGW-w64. Supports x86_64, x86_32, and arm64.

  • Python 3.9+. Make sure to enable the option to add Python to the PATH in 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=no SCons option if Direct3D 12 support is not desired).

Note

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

Note

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

Pour chaque sous-système MinGW de MSYS2, vous devez ensuite exécuter pip3 install scons dans sa console.

Voir aussi

Pour récupérer le code source de Godot pour le compiler, voir Obtenir la source.

Pour un aperçu général de l'utilisation de SCons pour Godot, voir Introduction au buildsystem.

Configuration de SCons

To install SCons, open the command prompt and run the following command:

python -m pip install scons

Si le message suivant s'affiche : Defaulting to user installation because normal site-packages is not writeable, il se peut que vous deviez exécuter à nouveau cette commande en utilisant des droits élevés. Ouvrez un nouvel invité de commande en tant qu'administrateur puis exécutez à nouveau la commande pour vous assurer que SCons est disponible depuis le PATH.

Pour vérifier si vous avez correctement installé Python et SCons, il faut taper python --version et scons --version dans l'invite de commande (cmd.exe).

Si les commandes ci-dessus ne fonctionnent pas, assurez-vous d'ajouter Python dans votre variable d'environnement PATH après son installation, puis vérifiez de nouveau. Vous pouvez le faire en exécutant de nouveau l'installateur Python et en activant l'option pour ajouter Python au PATH.

Si SCons n'arrive pas à détecter votre installation de Visual Studio, ça peut être pare que votre version de SCons est trop ancienne. Mettez-la à jour avec python -m pip install --upgrade scons.

Téléchargement des sources de Godot

Voir Obtenir la source pour plus d'informations.

Le tutoriel suppose que vous avez placé le code source dans le répertoire C:\godot.

Avertissement

Pour éviter les ralentissements causés par une recherche continue de virus pendant la compilation, ajoutez le dossier source de Godot à la liste des exceptions de votre logiciel antivirus.

For Windows Defender, hit the Windows key, type "Windows Security" then hit Enter. Click on Virus & threat protection on the left panel. Under Virus & threat protection settings click on Manage Settings and scroll down to Exclusions. Click Add or remove exclusions then add the Godot source folder.

Compilation

Sélection d'un compilateur

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.

Astuce

During development, using the Visual Studio compiler is usually a better idea, as it links the Godot binary much faster than MinGW. However, MinGW can produce more optimized binaries using link-time optimization (see below), making it a better choice for production use. This is particularly the case for the GDScript VM which performs much better with MinGW compared to MSVC. Therefore, it's recommended to use MinGW to produce builds that you distribute to players.

All official Godot binaries are built in custom containers using MinGW.

Exécuter SCons

After opening a command prompt, change to the root directory of the engine source code (using cd) and type:

C:\godot> scons platform=windows

Note

Lors de la compilation avec plusieurs threads CPU, Scons peut avertir à propos de pywin32. Vous pouvez ignorer cette avertissement en toute sécurité.

Astuce

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 Development and production aliases 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.

Ce fichier exécutable contient l'ensemble du moteur et peut s'exécuter sans aucune dépendance. L'exécuter fera apparaître le Gestionnaire de Projet.

Astuce

If you are compiling Godot for production use, you can make the final executable smaller and faster by adding the SCons option production=yes. This enables additional compiler optimizations and link-time optimization.

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.

Note

Si vous souhaitez utiliser des paramètres d'édition séparés pour vos propres constructions Godot et vos versions officielles, vous pouvez activer Mode autonome en créant un fichier appelé ._sc_ ou _sc_ dans le dossier bin/.

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. We compile the Mesa libraries you will need into a static library. Download it anywhere, unzip it and remember the path to the unzipped folder, you will need it below.

Note

You can optionally build the godot-nir-static libraries yourself with the following steps:

  1. Install the Python package mako which is needed to generate some files.

  2. Clone the godot-nir-static directory and navigate to it.

  3. 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.

Optionally, you can compile with the following for additional features:

  • PIX is a performance tuning and debugging application for Direct3D12 applications. If you compile-in support for it, you can get much more detailed information through PIX that will help you optimize your game and troubleshoot graphics bugs. To use it, download the WinPixEventRuntime package. You will be taken to a NuGet package page where you can click "Download package" to get it. Once downloaded, change the file extension to .zip and unzip the file to some path.

  • Agility SDK can be used to provide access to the latest Direct3D 12 features without relying on driver updates. To use it, download the latest Agility SDK package. You will be taken to a NuGet package page where you can click "Download package" to get it. Once downloaded, change the file extension to .zip and unzip the file to some path.

Note

If you use a preview version of the Agility SDK, remember to enable developer mode in Windows; otherwise it won't be used.

Note

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=<...>

Ou, avec toutes les options activées :

C:\godot> scons platform=windows mesa_libs=<...> agility_sdk_path=<...> pix_path=<...>

Note

PIX support is disabled by default, even if you have it installed. To enable it, pass use_pix=yes to SCons.

Note

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.

Note

You can optionally build the AccessKit libraries yourself with the following steps:

  1. Clone the godot-accesskit-c-static directory and navigate to it.

  2. 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.

Note

You can optionally build the WinRT headers yourself with the following steps:

  1. Clone the winrt-mingw directory and navigate to it.

  2. 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=<...>

Compiling with ANGLE support

ANGLE provides a translation layer from OpenGL ES 3.x to Direct3D 11 and can be used to improve support for the Compatibility renderer on some older GPUs with outdated OpenGL drivers and on Windows for ARM.

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.

Note

You can optionally build the godot-angle-static libraries yourself with the following steps:

  1. Clone the godot-angle-static directory and navigate to it.

  2. 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=<...>

Développement dans Visual Studio

L'utilisation d'un IDE n'est pas nécessaire pour compiler Godot, car SCons s'occupe de tout. Mais si vous avez l'intention de développer le moteur de jeu ou de déboguer son code C++, vous serez sûrement amenés à configurer un éditeur de code ou un IDE.

Les éditeurs basés sur des dossiers ne nécessitent aucune configuration particulière pour commencer à travailler avec la base de code de Godot. Pour éditer des projets avec Visual Studio, ils doivent être configurés comme une solution.

You can create a Visual Studio solution via SCons by running SCons with the vsproj=yes parameter, like this:

scons platform=windows vsproj=yes

Vous serez maintenant capable d'ouvrir les sources de Godot dans une solution Visual Studio, et à même de construire Godot en utilisant le bouton Build de Visual Studio.

Voir aussi

Voir Visual Studio pour plus de détails.

Dépannage

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 Continue without code, then Help > Check for Updates in the menu bar at the top. Install all updates, then try compiling again.

Compilation croisée pour Windows à partir d'autres systèmes d'exploitation

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"

Where /path/to/mingw is the path containing the bin directory where i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc are located (e.g. /opt/mingw-w64 if the binaries are located in /opt/mingw-w64/bin).

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

Note

If you are building with MinGW-LLVM, add use_llvm=yes to the scons command.

Note

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.

Dépannage

La compilation croisée à partir de certaines versions d'Ubuntu peut conduire à ce bogue, en raison d'une configuration par défaut ne supportant pas le threading POSIX.

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>

Création de modèles d'exportation Windows

Windows export templates are created by compiling Godot without the editor, with the following flags:

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

If you plan on replacing the standard export templates, copy these to the following location, replacing <version> with the version identifier (such as 4.2.1.stable or 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

Cependant, si vous utilisez des modules personnalisés ou un moteur de code personnalisé, vous pouvez plutôt vouloir configurer vos binaires comme modèles d'exportation personnalisés dans le menu d'exportation de projet. Vous devez avoir Options avancées activées pour définir ceci.

../../../_images/wintemplates.webp

Vous n'avez pas besoin de les copier dans ce cas, il suffit de référencer les fichiers résultants dans le répertoire bin\ de votre dossier source Godot, de sorte que la prochaine fois que vous construirez, vous aurez automatiquement les modèles personnalisés référencés.