A minimalist project using Godot's GDExtension using C++.
godot-cpp-exemplo/
├── godot-cpp/ # Godot C++ bindings
├── src/ # C++ source files
│ ├── GDExample.cpp # Example class implementation
│ ├── GDExample.h # Example class header
│ ├── register_types.cpp # Extension registration
│ └── register_types.h
├── projeto-com-cmaismais/ # Godot project
│ └── addons/
│ └── meu-plugin-em-cpp/
│ ├── bin/ # Compiled libraries
│ └── meu-plugin.gdextension
└── SConstruct # Build configuration
- Python 3.6+
- SCons build system
- C++ compiler (GCC, Clang, or MSVC)
- Git
- Clone the repository with submodules:
git clone --recursive <repository-url>If you already cloned without --recursive:
git submodule update --init --recursive- Build the C++ extension:
sconsFor release builds:
scons target=template_releaseThe compiled library will be placed in projeto-com-cmaismais/addons/meu-plugin-em-cpp/bin/.
Open the projeto-com-cmaismais folder in Godot Editor and the GDExtension will be automatically loaded.
The GDExample class extends Sprite2D and demonstrates:
- Custom methods callable from GDScript
- Exported properties visible in the Inspector
- Process loop integration
Use it in GDScript:
var example = GDExample.new()
example.variavel_do_export = 42
example.minha_funcao() # Prints the value- Create header and implementation files in
src/ - Register the class in
register_types.cpp:
ClassDB::register_class<YourClass>();- Rebuild with
scons
target=template_debugortarget=template_releaseplatform=linux,platform=windows,platform=macosarch=x86_64,arch=arm64, etc.
Example:
scons platform=linux target=template_release arch=x86_64MIT