How to automatically export .dll files?

Godot Version

Godot v3.5.2

Question

I want to use Discord SDK to setup Rich Presence with Godot 3 in C#. Discord SDK has .dll, .dylib and .so files and I want these files to:

  1. load when I start the game in the editor
  2. automatically export when I export my game. I only want to export specific files for specific platforms.

So in order to achieve this I did the following

  1. I put these files in the root folder of my project.
  2. I setup this GDNative singletion. I don’t exactly understand how it works, I looked it up in another plugin
[general]
singleton=true
load_once=true
symbol_prefix="discord_"
reloadable=false

[entry]
OSX.64=[ "res://discord_game_sdk.dylib" ]
Windows.64=[ "res://discord_game_sdk.dll" ]
X11.64=[ "res://discord_game_sdk.so" ]
Server=[ "res://discord_game_sdk.so" ]

[dependencies]
OSX.64=[ "res://discord_game_sdk.dylib" ]
Windows.64=[ "res://discord_game_sdk.dll" ]
X11.64=[ "res://discord_game_sdk.so" ]
Server=[ "res://discord_game_sdk.so" ]

After these procedures the Rich Presence worked both in the editor and after exporting the game.
However whenever I start the game or export it I get the following error in the Debugger

open_dynamic_library: Can't open dynamic library: 
[res://discord_game_sdk.dll], error: Error 126: The specified module could not be found.
  <C++ Error>   Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN
  <C++ Source>  platform/windows/os_windows.cpp:2372 @ open_dynamic_library()

The dynamic library clearly DOES open but this error makes me think that I do something wrong and my method is incorrect. How can I correctly export .dll files or how can I otherwise get rid of this error?

I assume you want to use C#'s Interop Services to access the library files? In that case I’m pretty sure you wouldn’t want the [entry] section, those would be libraries directly loaded by Godot as GDNative (or GDExtensions in Godot 4), not something you access through C#.

In addition, you should put those files into your own custom addons subfolder (together with your own cs binding code).

Yes, I want to use C# interop services. I guess what I basically want is to just load the dependencies without creating any gdnative libraries. However, if I just delete the [entry] section I get this error

initialize: No library set for this platform
  <C++ Source>  modules/gdnative/gdnative.cpp:293 @ initialize()

Hm, yeah, that’s something I completely forgot about. Not sure if your use case is currently covered then. Although I’ve never really used the .net version so far, so someone else might have more ideas here.

1 Like