What is GDNative?

Introduction

GDNative 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

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

Differences between GDNative and C++ modules

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

They also both allow you to integrate third-party libraries into Godot. The one you should choose depends on your needs.

Advantages of GDNative

Unlike modules, GDNative 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 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.

Also:

  • GDNative 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 GDNative 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.

  • GDNative 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 GDNative.

Advantages of C++ modules

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

  • C++ modules provide deeper integration into the engine. GDNative's access is limited to what the scripting API exposes.

  • You can use C++ modules to provide additional features in a project without carrying native library files around. This extends to exported projects.

  • C++ modules are supported on all platforms. In contrast, GDNative isn't supported on HTML5 and the Universal Windows Platform (UWP) yet.

  • C++ modules can be faster than GDNative, especially when the code requires a lot of communication through the scripting API.

Supported languages

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

Note

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

The bindings below are developed and maintained by the community:

Note

Not all bindings mentioned here may be production-ready. Make sure to research options thoroughly before starting a project with one of those. Also, double-check whether the binding is compatible with the Godot version you're using.