GDNative and languages compiling to C

Using 3.4.4 but about to upgrade to 4.

I’ve read the docs on GDNative and I am looking for a good solid example of binding it to an object file (.o) produced by a C compiler, I use a language called Mercury, and I wanted to test the waters to see what might be involved.

Mercury has a build tool, so if my project was called ‘foo’ then I just have to issue the command:

mmc --make libfoo

and I will end up with a shared object file.

My question is are there any concerns of name mangling etc that I might need to be wary of?

Thanks.

GDNative is supersceded by GDExtensions after 4.0 If you intend to upgrade, it’s not worth it to look into GDNative at this point.

I don’t know much about GDNative to be honest.


GDExtension requires a single C function entry point, named in a .gdextension file that looks something like this, the entry_symbol is the function symbol name of your C library.

[configuration]

entry_symbol = "example_library_init"
compatibility_minimum = "4.1"

[libraries]

windows.debug.x86_64 = "res://bin/libgdexample.windows.template_debug.x86_64.dll"
linux.debug.x86_64 = "res://bin/libgdexample.linux.template_debug.x86_64.so"

Here’s the best documentation I could find on binding through C manually so I could apply it to other C-interop languages as well.

https://github.com/gilzoide/hello-gdextension/blob/main/1.hello-c/README.md

Thanks! I think I meant GDExtensions actually!

I will try to find some time.

1 Like