Mirror of godotengine/godot-cpp
  • C++ 78.2%
  • Python 13.8%
  • CMake 6.6%
  • GDScript 1%
  • NASL 0.2%
  • Other 0.1%
Find a file
David Snopek 7e18e40d75
Merge pull request #2038 from dsnopek/variant-alignas-8
Ensure `Variant`'s are 8-byte aligned
2026-07-31 17:56:55 -05:00
.github Merge pull request #1978 from godotengine/dependabot/github_actions/actions/upload-artifact-7 2026-06-22 06:41:31 -07:00
cmake Sync defs.hpp with godot upstream. 2026-07-05 00:58:23 +02:00
gdextension gdextension: Sync with upstream commit 5b4e0cb0fd279832bbdd69fed5354d4e5ad26f88 (4.7-stable) 2026-06-18 15:26:36 -05:00
include/godot_cpp Merge pull request #2038 from dsnopek/variant-alignas-8 2026-07-31 17:56:55 -05:00
misc Generate GDExtension interface header and loader from JSON 2025-12-18 12:09:41 -06:00
natvis Add godot-cpp.natvis debug visualizers 2026-06-04 08:05:42 +02:00
src Merge pull request #2007 from Ijtihed/fix/scene-tree-get-singleton 2026-07-27 11:38:24 -05:00
test Merge pull request #2032 from Ivorforce/native-mutex 2026-07-29 09:40:28 -05:00
tools Merge pull request #2011 from shiena/fix/msvc-capture-log-encoding 2026-07-24 11:39:54 -05:00
.clang-format Don't right-align escaped newlines, e.g. for #define. This has previously led to long diffs in the commit history. 2026-06-08 15:06:15 +02:00
.editorconfig CI: Various version bumps; sync with main repo 2025-04-26 12:23:07 -05:00
.gdignore Add .gdignore file to godot-cpp, for use as submodule in Godot projects 2022-12-22 16:01:03 +01:00
.git-blame-ignore-revs Ignore right-align escaped newlines commit. 2026-06-08 15:06:37 +02:00
.gitattributes Add .editorconfig, consolidate .gitattributes 2024-06-25 08:46:06 -05:00
.gitignore Modernise Existing CMakeLists.txt 2024-11-21 11:01:00 +10:30
.gitmodules Remove godot-headers submodule, copy files directly 2022-03-15 10:19:07 +01:00
.pre-commit-config.yaml Generate GDExtension interface header and loader from JSON 2025-12-18 12:09:41 -06:00
binding_generator.py Merge pull request #2032 from Ivorforce/native-mutex 2026-07-29 09:40:28 -05:00
build_profile.py [Bindings] Build profile now strips methods and skip files 2025-01-07 20:33:12 +01:00
CMakeLists.txt Update godot-cpp's version in CMakeLists.txt for v10.0 2026-03-03 15:05:45 -06:00
doc_source_generator.py Generate GDExtension interface header and loader from JSON 2025-12-18 12:09:41 -06:00
LICENSE.md Sync license copyright with upstream GH-70885 2023-01-10 16:15:31 +01:00
make_interface_header.py gdextension: Sync with upstream commit 481f36ed20520db3195a09cc309abf48c03cf51a (4.6-rc1) 2026-01-15 08:35:40 -06:00
Makefile Update Makefile after recent buildsystem changes 2022-10-06 14:34:29 +02:00
pyproject.toml CI: Various version bumps; sync with main repo 2025-04-26 12:23:07 -05:00
README.md Improve V10.0 explanation 2026-02-20 20:14:09 +01:00
SConstruct Merge pull request #1669 from Ivorforce/scons-variant_dir-support 2025-07-03 12:17:32 -05:00

godot-cpp

Note

For GDNative (Godot 3.x), switch to the 3.x or the 3.6 branch.

This repository contains the C++ bindings for the Godot Engine's GDExtensions API.

Versioning

Warning

The master branch of godot-cpp (version 10.x) is currently in Beta. You may prefer to choose a previous version to build on top of instead:

Starting with version 10.x, godot-cpp is versioned independently from Godot. Using the api_version parameter (see below), godot-cpp v10 can target Godot 4.3 or later (including 4.6).

Until we have a stable release branch, you can use the master branch (v10), or choose any of the previous version branches and tags for your project.

Compatibility

GDExtensions targeting an earlier version of Godot should work in later minor versions, but not vice-versa. For example, a GDExtension targeting Godot 4.3 should work just fine in Godot 4.4, but one targeting Godot 4.4 won't work in Godot 4.3.

You can specify which version you are targeting with the api_version option:

scons api_version=4.3

... or by providing a custom extension_api.json generated by the Godot version you are targeting:

godot --dump-extension-api
scons custom_api_file=extension_api.json

If you don't provide api_version or custom_api_file, then, by default, godot-cpp will target the latest stable Godot version that it's aware of.

Contributing

We greatly appreciate help in maintaining and extending this project. If you wish to help out, please visit the godot-cpp section of the Contributing docs.

Getting started

You need the same C++ pre-requisites installed that are required for the godot repository. Follow the official build instructions for your target platform.

Building your extension will create a shared library. To use this in your Godot project you'll need a .gdextension file, for example:

[configuration]

entry_symbol = "example_library_init"
compatibility_minimum = "4.1"

[libraries]

macos.debug = "res://bin/libgdexample.macos.debug.framework"
macos.release = "res://bin/libgdexample.macos.release.framework"
windows.debug.x86_64 = "res://bin/libgdexample.windows.debug.x86_64.dll"
windows.release.x86_64 = "res://bin/libgdexample.windows.release.x86_64.dll"
linux.debug.x86_64 = "res://bin/libgdexample.linux.debug.x86_64.so"
linux.release.x86_64 = "res://bin/libgdexample.linux.release.x86_64.so"
# Repeat for other architectures to support arm64, rv64, etc.

See the example.gdextension used in the template project for a complete example.

The entry_symbol is the name of the function that initializes your library, for example:

extern "C" {

// Initialization.

GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
	godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);

	init_obj.register_initializer(initialize_example_module);
	init_obj.register_terminator(uninitialize_example_module);
	init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);

	return init_obj.init();
}
}

The initialize_example_module() should register the classes in ClassDB, similar to a Godot module:

using namespace godot;
void initialize_example_module(ModuleInitializationLevel p_level) {
	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
		return;
	}
	GDREGISTER_CLASS(Example);
}

Any node and resource you register will be available in the corresponding Create... dialog. Any class will be available to scripting as well.

Examples and templates

See the godot-cpp-template project for a generic reusable template.

Or checkout the code for the Summator example as shown in the official documentation.