Question
How to How to develop C++ GdExtensions with Rider on Linux?
Answer
Starting from 2026.1 Rider supports CMake, which allows building/running/debugging CMake projects. There is a template for creating GdExtensions available on GitHub: https://github.com/godotengine/godot-cpp-template. It is recommended to start using this official project template.
Steps:
-
Clone https://github.com/godotengine/godot-cpp-template or download the zip. Rename the resulting directory.
-
git clone git@github.com:godotengine/godot-cpp-template.git ./MyGdExtensionProjectName;
-
-
Open the resulting directory and ensure to pull godot-cpp repository (a submodule of godot-cpp-template):
cd MyGdExtensionProjectName; # The cloned/unarchived directory git submodule update --init; -
As recommended in the readme file, it is necessary to edit several placeholders in the configuration files:
-
Change the
entry_symbolstring inside project/bin/example.gdextension file, e.g.MyGdExtensionProjectName_init- rename the
example_library_initfunction in src/register_types.cpp to the same name you chose forentry_symbol.
- rename the
-
Replace
EXTENSION-NAME(40 entries) in project/bin/example.gdextension to the choosen name of your extension, e.g.MyGdExtension -
Rename the example.gdextension to a choosen name, e.g.
MyGdExtension.gdextension; -
Open
MyGdExtensionProjectName/CMakeList.txt. Edit as follows:- set(LIBNAME "EXTENSION-NAME" CACHE STRING "The name of the library") + set(LIBNAME "MyGdExtension" CACHE STRING "The name of the library") - OUTPUT_NAME "${LIBNAME}${GODOTCPP_SUFFIX}" + OUTPUT_NAME "lib${LIBNAME}${GODOTCPP_SUFFIX}" # the resulting OUTPUT_NAME should match name of the library in ./project/bin/MyGdExtension.gdextension file # e.g. Having this in MyGdExtension.gdextension: # linux.x86_64.single.debug = "./linux/libMyGdExtension.linux.template_debug.x86_64.so" # The OUTPUT_NAME row in CMakeList.txt should be: # OUTPUT_NAME "lib${LIBNAME}${GODOTCPP_SUFFIX}" -
(Optional) edit the following lines in CMakeList.txt. This project data can be edited later when necessary:
project(godot-cpp-template VERSION 1.0 DESCRIPTION "This repository serves as a quickstart template for GDExtension development with Godot 4.0+." HOMEPAGE_URL "https://github.com/enetheru/godot-cpp-template/tree/main" LANGUAGES CXX )
-
-
Now, depending on the way the above steps are performed, do below:
- Above steps are done outside Rider: just open the project in Rider. Select CMakeList.txt file in the Open Solution dialog;
- You opened the project in Rider already, ensure to follow the below steps:
- Enable "Show All Files" and delete the
cmake-build-debugdirectory (select -> press the "Delete" key): - Open the CMake tool window: View | Tool Windows | CMake;
- Click Reload CMake Project:
- Enable "Show All Files" and delete the
-
Find and open for edit the run configuration named as your GdExtension:
-
Specify the below fields. Create an extra run configuration if necessary:
- "Executable" - point to exact Godot executable, e.g.
Godot_v4.6.1-stable_linux.x86_64 - "Program arguments":
--editorstands for launching the Godot editor itself. Or leave it empty. One can duplicate the run configuration and have two different configurations: for running the game and for running the editor; - "Working directory" - point to the directory with
project.godotfile ({ProjectRoot}/project/)
- "Executable" - point to exact Godot executable, e.g.
-
Save changes;
-
Set the Debugger in File | Settings | Build, Execution, Deployment | Toolchains to Bundled LLDB;
-
Launch the editor at least once to be able to run/debug the game.
Now you can run/debug the gdextension. Try setting a breakpoint in src/example_class.cpp:8, then start the Debug of game configuration ( the one without --editor argument).
Comments
0 comments
Please sign in to leave a comment.