godot-cpp: Visual Studio 2022 GDExtension C++ ".lib" binding error

Godot version

4.2 stable

System information

windows 11, intel i5 10ma, rx 6600 xt,godot 4.2 stable

Issue description

Compile GDextension with Visual studio 2022, I can run godot, but it does not compile correctly, it seems that there is a problem and incompatibility with the .lib generated with the binding in godot-cpp

libgodot-cpp.windows.template_debug.x86_64.lib(error_macros.windows.template_debug.x86_64.obj) : error LNK2038: mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in register_types.obj

02_ErrorVisualStudioGDExtension 01_ErrorVisualStudioGDExtension 04_ErrorVisualStudioGDExtension 16_configuration

Steps to reproduce

in windows 11 install visual studio 2022 with libraries, python, scons and git. 17_configuration

Download this template project that is fully configured and press F5, you will see that it loads the game from godot, but it does not compile https://gitlab.com/kone9/visual-studio-godot-engine-gdextension-cpp-template

try to generate the .lib in godot-cpp with different configurations, For example, I already tried this one and it doesn’t work. Captura de pantalla 2023-12-03 153455

scons platform=windows custom_api_file=gdextension\extension_api.json generate_bindings=yes

The issue is that Visual Studio does not need scons to generate the DLL, but to generate the .lib you have to use scons. I don’t know what the error would be, but it seems that there is a problem with the .lib generated with scons in godot-cpp

Minimal reproduction project

I created this project where it is explained in detail how to configure Visual Studio with GDextension, but for some reason it doesn’t work. I also want to clarify that I did this configuration previously with GDnative and it did work, although obviously the includes were different. Please look at this project carefully because it contains all the configurations in visual studio 2022 in detail and it is an example of a downloadable template that should be able to be used anywhere. Open the project with visual studio 2022 stable version

https://gitlab.com/kone9/visual-studio-godot-engine-gdextension-cpp-template

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 74 (15 by maintainers)

Most upvoted comments

GDNative isn’t supported in 4.2, do you mean GDExtension?

Yes, sorry… sorry I was wrong… The problem is with GDextension.