godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Unable to use Godot 4.2 interface with godot-cpp for 4.5 beta5

Open 3ddelano opened this issue 4 months ago • 2 comments

Godot version

v4.5.beta5.official (c81fd6c51233a727da528cf7f74137d56b5d6efe)

godot-cpp version

4.5-beta5: (1421ba26ad045fb23b35ad7360cf5b2f1de55738)

System information

macOS 15.6, Apple M3 Pro

Issue description

Update: Using the gdextension interface and api generated from Godot 4.4.1 stable also doesnt work with godot-cpp for Godot 4.5 beta5

I'm using the godot-cpp for Godot 4.5beta5 with the scons gdextension_dir flag pass it the gdextension_interface.h and extension_api.json generated by Godot 4.2 stable. But I get the following errors when trying to build the gdextension with scons.

Trying to build the gdextension from the godot-cpp-template repo using the command: scons gdextension_dir=gdext-api/

Gives the following error:

scons: Building targets ...
Generating thirdparty/godot-cpp/gen/include/godot_cpp/core/ext_wrappers.gen.inc ...
Built-in type config: float_64
Compiling thirdparty/godot-cpp/src/core/memory.cpp ...
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:43:12: error: unknown type name 'GDExtensionGodotVersion2'; did you mean 'GDExtensionGodotVersion'?
   43 | extern "C" GDExtensionGodotVersion2 godot_version;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionGodotVersion
gdext-api/gdextension_interface.h:616:3: note: 'GDExtensionGodotVersion' declared here
  616 | } GDExtensionGodotVersion;
      |   ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:46:12: error: unknown type name 'GDExtensionInterfaceGetGodotVersion2'; did you mean 'GDExtensionInterfaceGetGodotVersion'?
   46 | extern "C" GDExtensionInterfaceGetGodotVersion2 gdextension_interface_get_godot_version2;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceGetGodotVersion
gdext-api/gdextension_interface.h:626:16: note: 'GDExtensionInterfaceGetGodotVersion' declared here
  626 | typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
      |                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:84:12: error: unknown type name 'GDExtensionInterfaceVariantGetObjectInstanceId'
   84 | extern "C" GDExtensionInterfaceVariantGetObjectInstanceId gdextension_interface_variant_get_object_instance_id;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:90:12: error: unknown type name 'GDExtensionInterfaceGetVariantGetInternalPtrFunc'
   90 | extern "C" GDExtensionInterfaceGetVariantGetInternalPtrFunc gdextension_interface_variant_get_ptr_internal_getter;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:112:12: error: unknown type name 'GDExtensionInterfaceStringNewWithUtf8CharsAndLen2'; did you mean 'GDExtensionInterfaceStringNewWithUtf8CharsAndLen'?
  112 | extern "C" GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceStringNewWithUtf8CharsAndLen
gdext-api/gdextension_interface.h:1457:16: note: 'GDExtensionInterfaceStringNewWithUtf8CharsAndLen' declared here
 1457 | typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
      |                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:114:12: error: unknown type name 'GDExtensionInterfaceStringNewWithUtf16CharsAndLen2'; did you mean 'GDExtensionInterfaceStringNewWithUtf16CharsAndLen'?
  114 | extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceStringNewWithUtf16CharsAndLen
gdext-api/gdextension_interface.h:1469:16: note: 'GDExtensionInterfaceStringNewWithUtf16CharsAndLen' declared here
 1469 | typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
      |                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:154:12: error: unknown type name 'GDExtensionInterfacePackedVector4ArrayOperatorIndex'
  154 | extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:155:12: error: unknown type name 'GDExtensionInterfacePackedVector4ArrayOperatorIndexConst'
  155 | extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:161:12: error: unknown type name 'GDExtensionInterfaceDictionarySetTyped'; did you mean 'GDExtensionInterfaceArraySetTyped'?
  161 | extern "C" GDExtensionInterfaceDictionarySetTyped gdextension_interface_dictionary_set_typed;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceArraySetTyped
gdext-api/gdextension_interface.h:2088:16: note: 'GDExtensionInterfaceArraySetTyped' declared here
 2088 | typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script);
      |                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:174:12: error: unknown type name 'GDExtensionInterfaceObjectHasScriptMethod'; did you mean 'GDExtensionInterfaceObjectGetScriptInstance'?
  174 | extern "C" GDExtensionInterfaceObjectHasScriptMethod gdextension_interface_object_has_script_method;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceObjectGetScriptInstance
gdext-api/gdextension_interface.h:2367:44: note: 'GDExtensionInterfaceObjectGetScriptInstance' declared here
 2367 | typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
      |                                            ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:175:12: error: unknown type name 'GDExtensionInterfaceObjectCallScriptMethod'; did you mean 'GDExtensionInterfaceObjectGetScriptInstance'?
  175 | extern "C" GDExtensionInterfaceObjectCallScriptMethod gdextension_interface_object_call_script_method;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceObjectGetScriptInstance
gdext-api/gdextension_interface.h:2367:44: note: 'GDExtensionInterfaceObjectGetScriptInstance' declared here
 2367 | typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
      |                                            ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:176:12: error: unknown type name 'GDExtensionInterfaceCallableCustomCreate2'; did you mean 'GDExtensionInterfaceCallableCustomCreate'?
  176 | extern "C" GDExtensionInterfaceCallableCustomCreate2 gdextension_interface_callable_custom_create2;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceCallableCustomCreate
gdext-api/gdextension_interface.h:2382:16: note: 'GDExtensionInterfaceCallableCustomCreate' declared here
 2382 | typedef void (*GDExtensionInterfaceCallableCustomCreate)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_callable_custom_info);
      |                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:180:12: error: unknown type name 'GDExtensionInterfaceScriptInstanceCreate3'
  180 | extern "C" GDExtensionInterfaceScriptInstanceCreate3 gdextension_interface_script_instance_create3;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:184:12: error: unknown type name 'GDExtensionInterfaceObjectSetScriptInstance'; did you mean 'GDExtensionInterfaceObjectGetScriptInstance'?
  184 | extern "C" GDExtensionInterfaceObjectSetScriptInstance gdextension_interface_object_set_script_instance;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceObjectGetScriptInstance
gdext-api/gdextension_interface.h:2367:44: note: 'GDExtensionInterfaceObjectGetScriptInstance' declared here
 2367 | typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
      |                                            ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:185:12: error: unknown type name 'GDExtensionInterfaceClassdbConstructObject2'; did you mean 'GDExtensionInterfaceClassdbConstructObject'?
  185 | extern "C" GDExtensionInterfaceClassdbConstructObject2 gdextension_interface_classdb_construct_object2;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceClassdbConstructObject
gdext-api/gdextension_interface.h:2411:32: note: 'GDExtensionInterfaceClassdbConstructObject' declared here
 2411 | typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname);
      |                                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:188:12: error: unknown type name 'GDExtensionInterfaceClassdbRegisterExtensionClass5'
  188 | extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass5 gdextension_interface_classdb_register_extension_class5;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:190:12: error: unknown type name 'GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod'; did you mean 'GDExtensionInterfaceClassdbRegisterExtensionClassMethod'?
  190 | extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod gdextension_interface_classdb_register_extension_class_virtual_method;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            GDExtensionInterfaceClassdbRegisterExtensionClassMethod
gdext-api/gdextension_interface.h:2484:16: note: 'GDExtensionInterfaceClassdbRegisterExtensionClassMethod' declared here
 2484 | typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
      |                ^
In file included from thirdparty/godot-cpp/src/core/memory.cpp:31:
In file included from thirdparty/godot-cpp/include/godot_cpp/core/memory.hpp:38:
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:201:12: error: unknown type name 'GDExtensionInterfaceEditorRegisterGetClassesUsedCallback'
  201 | extern "C" GDExtensionInterfaceEditorRegisterGetClassesUsedCallback gdextension_interface_editor_register_get_classes_used_callback;
      |            ^
thirdparty/godot-cpp/include/godot_cpp/godot.hpp:202:12: error: unknown type name 'GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars'
  202 | extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars;
      |            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
scons: *** [thirdparty/godot-cpp/gen/include/godot_cpp/core/ext_wrappers.gen.inc] KeyError : 'hash'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/scons/4.9.1/libexec/lib/python3.13/site-packages/SCons/Action.py", line 1434, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/myproject/thirdparty/godot-cpp/tools/godotcpp.py", line 161, in scons_generate_bindings
    _generate_bindings(
    ~~~~~~~~~~~~~~~~~~^
        api,
        ^^^^
    ...<4 lines>...
        env["godot_cpp_gen_dir"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/myproject/thirdparty/godot-cpp/binding_generator.py", line 305, in _generate_bindings
    generate_engine_classes_bindings(api, target_dir, use_template_get_node)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/myproject/thirdparty/godot-cpp/binding_generator.py", line 1502, in generate_engine_classes_bindings
    generate_engine_class_header(class_api, used_classes, fully_used_classes, use_template_get_node)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/myproject/thirdparty/godot-cpp/binding_generator.py", line 1715, in generate_engine_class_header
    result.append(f"\t\t\tBIND_VIRTUAL_METHOD(T, {method_name}, {method['hash']});")
                                                                 ~~~~~~^^^^^^^^
KeyError: 'hash'
scons: *** [thirdparty/godot-cpp/src/core/memory.macos.template_debug.universal.o] Error 1
scons: building terminated because of errors.

Steps to reproduce

  • Clone the minimal reproducible project
  • Update the git submodules using the command git submodule update --init
  • Run the command chmod +x ./build_debug.sh
  • Run the command ./build_debug.sh

Minimal reproduction project

https://github.com/3ddelano/godot4.5_beta5_issue_with_godot4.2

3ddelano avatar Aug 19 '25 13:08 3ddelano

Unfortunately, with the way that we are currently managing godot-cpp via branches, this can't work.

If we ended up adopting this proposal, then it could be possible to use the latest version of godot-cpp built for older versions of Godot

Although, I suppose we could go half-way there? We could start gating our use of functions from gdextension_interface.h based on the version from extension_api.json, while still using branches, although this could make cherry-picking to older versions tricky (or at least requiring an occasional sync with the latest version?)

dsnopek avatar Aug 19 '25 13:08 dsnopek

Oh, please close the issue then if its expected.

3ddelano avatar Aug 19 '25 13:08 3ddelano