godotgdextension

How do I specify shared library dependencies in the .gdextension file [dependencies] section?


The godot documentation for GDExtension in C++ specifies:

Finally, the dependencies section allows you to name additional dynamic libraries that should be included as well.

https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html#using-the-gdextension-module

Yet it has no example of it's usage and I cannot extrapolate from the [libraries] section example. For instance how do I include multiple different shared libraries as dependencies?

I cannot find any further documentation for the .gdextension file.

Is there any documentation for this? Is there an example usage? :)


Solution

  • After some digging around in the godot-cpp repository, I found this example file: https://github.com/godotengine/godot-cpp/blob/master/test/project/example.gdextension

    [configuration]
    
    entry_symbol = "example_library_init"
    compatibility_minimum = "4.1"
    
    [libraries]
    . . .
    

    with the dependency section:

    [dependencies]
    ios.debug = {
      "res://bin/libgodot-cpp.ios.template_debug.xcframework": ""
    }
    ios.release = {
      "res://bin/libgodot-cpp.ios.template_release.xcframework": ""
    }
    

    It seems from this example, shared library dependencies are listed as dictionary key entries.

    According to the docs:

    In addition, you are able to set an optional subdirectory to move your dependencies into. If no path is supplied Godot will move the libraries into the same directory as your game executable.

    The docs also include this example:

    [dependencies]
    macos.release = {
        "res://bin/libdependency.macos.template_release.framework" : "Contents/Frameworks"
    }
    windows.debug = {
        "res://bin/libdependency.windows.template_debug.x86_64.dll" : ""
    }
    

    So in this example, when building a macos.release this will depend on template_release.framework which will be moved into the Contents/Frameworks directory. But when building windows.debug, this will depend on template_debug.x86_64.dll which will be moved into the same directory as your game executable.