Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

What is GDExtension?

Introduction

GDExtension is a Godot-specific technology that lets the engine interact with native shared libraries at run-time. You can use it to run native code without compiling it with the engine.

Note

GDExtension is not a scripting language and has no relation to GDScript.

Differences between GDExtension and C++ modules

You can use both GDExtension and C++ modules to run C or C++ code in a Godot project.

Ils vous permettent également tous deux d'intégrer des bibliothèques tierces dans Godot. Le choix de l'une ou l'autre dépend de vos besoins.

Avertissement

Our long-term goal is that GDExtensions targeting an earlier version of Godot will work in later minor versions, but not vice-versa. For example, a GDExtension targeting Godot 4.2 should work just fine in Godot 4.3, but one targeting Godot 4.3 won't work in Godot 4.2.

However, GDExtension is currently experimental, which means that we may break compatibility in order to fix major bugs or include critical features. For example, GDExtensions created for Godot 4.0 aren't compatible with Godot 4.1 (see Updating your GDExtension for 4.1).

Advantages of GDExtension

Unlike modules, GDExtension doesn't require compiling the engine's source code, making it easier to distribute your work. It gives you access to most of the API available to GDScript and C#, allowing you to code game logic with full control regarding performance. It's ideal if you need high-performance code you'd like to distribute as an add-on in the asset library.

Aussi :

  • GDExtension is not limited to C and C++. Thanks to third-party bindings, you can use it with many other languages.

  • You can use the same compiled GDExtension library in the editor and exported project. With C++ modules, you have to recompile all the export templates you plan to use if you require its functionality at run-time.

  • GDExtension only requires you to compile your library, not the whole engine. That's unlike C++ modules, which are statically compiled into the engine. Every time you change a module, you need to recompile the engine. Even with incremental builds, this process is slower than using GDExtension.

Avantages des modules C++

We recommend C++ modules in cases where GDExtension isn't enough:

  • C++ modules provide deeper integration into the engine. GDExtension's access is not as deep as static modules.

  • Vous pouvez utiliser des modules C++ pour fournir des fonctionnalités supplémentaires dans un projet sans avoir à transporter des fichiers de bibliothèque natifs. Ceci s'étend aux projets exportés.

Note

If you notice that specific systems are not accessible via GDExtension but are via custom modules, feel free to open an issue on the godot-cpp repository to discuss implementation options for exposing the missing functionality.

Langages supportés

The Godot developers officially support the following language bindings for GDExtension:

Note

There are no plans to support additional languages with GDExtension officially. That said, the community offers several bindings for other languages (see below).

Ces liaisons sont développées et gérées par la communauté :

Note

Toutes les reliures mentionnées ici ne sont pas forcément prêtes pour la production. Veillez à bien étudier les options avant de commencer un projet avec l'une d'entre elles. Vérifiez également si la reliure est compatible avec la version de Godot que vous utilisez.

Compatibilité des versions

GDExtension add-ons compiled for a given Godot version are only guaranteed to work with the same minor release series. For example, a GDExtension add-on compiled for Godot 4.0 will only work with Godot 4.0, 4.0.1, 4.0.2. In addition, GDExtension is not compatible with Godot 3.x.

GDExtension add-ons are also only compatible with engine builds that use the level of floating-point precision the extension was compiled for. This means that if you use a engine build with double-precision floats, the extension must also be compiled for double-precision floats. See Large world coordinates for details.