Godot has become one of the most popular game engines of the last few years. It is free, open source under the MIT license, and small enough to download and start using in minutes. Most Godot games are written in GDScript, the engine's own scripting language. Sooner or later, though, many projects need something that already exists as a C or C++ library: a simulation library, a database, a networking protocol, a machine learning runtime. GDScript cannot call native code, but Godot can load it through GDExtension, and godot-cpp, the official C++ bindings, lets you expose that code as regular engine classes.
Writing the C++ code is the easy part. The hard part is the build: godot-cpp has to match your Godot version, and every library you add has to be compiled for each platform you ship to. In this post we give a short tour of Godot, explain how C++ extensions work, and show how to bring C++ libraries into a Godot game with Conan and godot-cpp 10, now available in Conan Center. As an example we will use flecs, an Entity Component System library, to simulate 100,000 particles inside a Godot scene.
GDExtension loads a shared library (.dll, .so, .dylib, or .wasm on the web) into an official, unmodified Godot build at runtime. The engine talks to the library through a stable C interface. GDExtension is the recommended approach for most projects, and it is how many popular plugins are distributed today. Because the C interface is verbose to use directly, the Godot team maintains godot-cpp, a C++ library that wraps it with an API very close to the one used inside the engine. Since version 10.0, a single godot-cpp release works with any Godot version from 4.3 onwards.
We will use flecs to simulate 100,000 particles inside a Godot scene, fleeing from the mouse cursor. Download the video to see the full simulation in action.