'Godot app stop working when added external DLL

I have a problem using external DLL-s in Godot and would like to ask for advice.

I use Godot with Rust. For that, I compile a DLL which contains the game logic written in Rust (dylib.dll). So far everything is good, my application can be run.

Now I added an other external library to the stack (ValveSoftware/GameNetworkingSockets, GNS) as a DLL. This DLL is referenced only by my game logic dll (dylibd.dll), and Godot does not know about it. My game-logic-dll compiles fine referencing GNS.

Now when I start my Godot app, I get an error whic says:

    ERROR: Can't open dynamic library: project/libs/dylib.dll, error: Error 126: The specified module could not be found. 
.
    At: platform/windows/os_windows.cpp:2395 
ERROR: get_symbol: No valid library handle, can't get symbol from GDNative object    
    At: modules/gdnative/gdnative.cpp:501 
ERROR: init_library: No nativescript_init in "res://libs/dylib.dll" found    
    At: modules/gdnative/nativescript/nativescript.cpp:1506

Sidenotes:

  • It works on linux without any issue, the problem occurs only on windows.
  • I use nightly-x86_64-pc-windows-msvc rust toolchain
  • The GameNetworkingSockets was built on the same machine, I think the vcpkg builder uses Visual Studio for the build.
  • all the required DLLs (my game logic DLL and the lib's DLL) is in the Working directory.

Any idea?



Solution 1:[1]

I have found the issue :)

The problem was really simple, the main issue here is rather the misleading and lacking error message from Windows.

The issue was that my external DLL also depends on other DLL-s as well, which windows could not find on its searching paths (in this case, libprotobuf.dll, libssl.dll, libcrypto.dll).

On my linux machines those shared libraries probably were already installed, that is why it worked there but not on Windows.

This tool also helped me al ot: https://docs.microsoft.com/en-us/sysinternals/downloads/procmon#download

With this tool it was easy to spot that my app tried to load the aforementioned DLL-s but could not find them.

Solution 2:[2]

I had the same problem. I developed a project with Godot on my pc (Win 10). Then I moved the same project on another pc (Win 10). When I tried to import the project I found the "ERROR: Can't open dynamic library: C:/GodotProjects/mylib.dll, error: Error 126: The specified module could not be found." The new pc needed some Visual C++ Redistributable packages:

Visual C++ Redistributable package

I hope this could help you

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Modamog
Solution 2 Andrea Cassigoli