Godot is a widely used open-source game engine that primarily uses its own scripting language, GDScript, for game logic. While GDScript offers immediate feedback and ease of use, it cannot directly call native C or C++ code. To bridge this gap, Godot provides the GDExtension interface, which allows loading shared libraries at runtime. The official godot-cpp bindings wrap GDExtension's C API, offering a C++ interface that mirrors the engine's internal API. This enables developers to write extensions in C++ that appear as regular engine classes in the Godot editor, complete with editable properties in the Inspector and usability from GDScript just like built-in nodes.

A significant challenge in using C++ extensions with Godot is managing the build process for godot-cpp and any third-party libraries across different platforms, architectures, and build types (such as debug and release). Traditionally, this required compiling godot-cpp and each dependency separately for every target, leading to redundant work and complexity. The Conan package manager simplifies this by offering a pre-built godot-cpp recipe in ConanCenter. This package exposes two key options: api_version (to select the Godot API version, ranging from 4.3 to 4.7) and target (to choose between template_debug, template_release, or editor). Each unique combination of these options is built once and cached, allowing multiple projects to reuse the same binaries without recompilation. Developers simply declare godot-cpp and their desired libraries as dependencies in a conanfile.py, and Conan handles resolution, downloading of precompiled binaries, source builds, and CMake integration.

To demonstrate the workflow, the blog post presents an example that integrates the flecs Entity Component System library to simulate 100,000 particles within a Godot scene. The example defines a Swarm node that inherits from Node2D and manages a flecs world where each particle is an entity with Position and Velocity components. A flecs system updates each particle's position to flee from the mouse cursor and bounce off window edges every frame. For efficient rendering, the positions are copied into a MultiMesh, which draws many instances of a single mesh in one draw call. The corresponding conanfile.py declares dependencies on godot-cpp/10.0.0 and flecs/4.1.6, and the CMakeLists.txt links the shared library against both. After building with Conan, the resulting extension is loaded by Godot 4.7, making the Swarm node available in the editor's Create New Node dialog under Node2D, where its count and flee_radius properties can be adjusted in the Inspector.

Godot editor showing the Swarm node selected with Count and Flee Radius properties visible in the Inspector
The Swarm node in Godot's Inspector with adjustable Count and Flee Radius propertiesblog.conan.io

This image illustrates the Swarm node extension appearing in the Godot editor after being built with Conan, allowing users to adjust its properties directly in the Inspector.