skip to Main Content

I would like to create modules for Godot using C++.
For that I followed this tutorial https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html.

I’m using the following environment : MSYS2 with g++ v13.2 on Windows 11, python 3.11.4 and Visual Studio Code.

So, I cloned this repo https://github.com/godotengine/godot-cpp/tree/4.1 and built it with the following command
scons platform=windows -j8 use_mingw=yes. It created this static library under the bin/ folder libgodot-cpp.windows.template_debug.x86_64.a.

My first questions are : Is it bad if I have a .a file instead of a .lib file on windows to make a Godot project works ? If yes, how can I build a .lib file ? Do I have to change something in my environment ?

I then continued to follow the GDExtension tutorial and I ended up with these errors in the godot output terminal :

Godot Engine v4.1.1.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
  modules/gltf/register_types.cpp:73 - Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
--- Debug adapter server started ---
--- GDScript language server started ---
  Attempt to get non-existent interface function: string_resize
  Unable to load GDExtension interface function string_resize()
  core/extension/gdextension.cpp:476 - GDExtension initialization function 'example_library_init' returned an error.
  Failed loading resource: res://bin/gdexample.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

Can someone help me resolve this please ?

2

Answers


  1. try cloning the exact version you’re using, for example tag godot-4.1.1-stable.

    relevant: https://github.com/godotengine/godot-cpp/issues/1201

    Login or Signup to reply.
  2. First, as the other answer points out, make sure godot-cpp and godot are the same exact version.

    Second:

    libgodot-cpp.windows.template_debug.x86_64.a is not the shared library for the example extension you build in the tutorial, it’s a static library for GDExtension itself.

    If you follow the tutorial instructions exactly, when you run scons it should build …/libgdexample.windows.template_debug.x86_64.dll in addition to
    libgodot-cpp.windows.template_debug.x86_64.a. This dll file is your actual extension.

    You need to download a SConstruct file from the tutorial and place it in your GDExtension folder (this is easy to miss, search the page for "Compiling the plugin"). https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search