How do i use GDExtensions with VisualStudio 2019?

Godot Version

Godot Version 4.0, 4.1, 4.1.1, 4.2

Question

Please help! I’ve been trying for about 5hours a day-or-so for almost 2 weeks and I still can’t seem to get it working…

I’m trying to use GDExtensions so I can write C++ code in godot4+ in visual studio 2019, but I get nothing but failed attempts…

( I’ve read the documentations and bounced around for a while and I don’t really understand it :frowning: )

I also watched a few different video tutorials, and the closest i’ve gotten, was following ‘Introduction to GDExtension by David Snopek Godot Wisconsin’, but I ended up completely stuck at some error code about godot needing to be opened in the editor at least once, and I’ve no idea how to do this (I saw in the video that they typed “godot4 --editor .&” but when i try this, it doesn’t do anything for some reason(if this is what its after))

please can anyone help?
Thanks so much for reading and any responses

Just spent the time from then until now trying again, but even still I just get:

core/extension/gdextension.cpp:865 - GDExtension configuration file must contain a “configuration/entry_symbol” key: res://bin/gdexample.gdextension

Failed loading resource: res://bin/gdexample.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

:frowning:

i still cant get this working

Is there a “configuration/entry_symbol” project in your configuration file? Also, if there are comments in the configuration file, remove them.

Sounds like your gdexample.gdextension file is missing the top [configuration] section here is what mine looks like.

[configuration]

entry_symbol = "twk_source_init"
compatibility_minimum = "4.1"

[libraries]

macos.debug = "res://bin/libTWKSource.macos.template_debug.framework"
macos.release = "res://bin/libTWKSource.macos.template_release.framework"
windows.debug.x86_32 = "res://bin/libTWKSource.windows.template_debug.x86_32.dll"
windows.release.x86_32 = "res://bin/libTWKSource.windows.template_release.x86_32.dll"
windows.debug.x86_64 = "res://bin/libTWKSource.windows.template_debug.x86_64.dll"
windows.release.x86_64 = "res://bin/libTWKSource.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "res://bin/linux/libTWKSource.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://bin/linux/libTWKSource.linux.template_release.x86_64.so"
linux.debug.arm64 = "res://bin/linux/libTWKSource.linux.template_debug.arm64.so"
linux.release.arm64 = "res://bin/linux/libTWKSource.linux.template_release.arm64.so"
linux.debug.rv64 = "res://bin/linux/libTWKSource.linux.template_debug.rv64.so"
linux.release.rv64 = "res://bin/linux/libTWKSource.linux.template_release.rv64.so"
android.debug.x86_64 = "res://bin/libTWKSource.android.template_debug.x86_64.so"
android.release.x86_64 = "res://bin/libTWKSource.android.template_release.x86_64.so"
android.debug.arm64 = "res://bin/libTWKSource.android.template_debug.arm64.so"
android.release.arm64 = "res://bin/libTWKSource.android.template_release.arm64.so"

Make sure your entry_symbol matches the function that loads gdextension, here is my entry function definition

extern "C" {
// Initialization
GDExtensionBool GDE_EXPORT
twk_source_init(GDExtensionInterfaceGetProcAddress p_get_proc_address,
		GDExtensionClassLibraryPtr p_library,
		GDExtensionInitialization *r_initialization) {
	GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library,
			r_initialization);
	init_obj.register_initializer(initialize_gdextension_types);
	init_obj.register_terminator(uninitialize_gdextension_types);
	init_obj.set_minimum_library_initialization_level(
			MODULE_INITIALIZATION_LEVEL_SCENE);

	return init_obj.init();
}
}