Exported Win64 build cannot find GDNative DLL on another PC

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By upperclasslemon

Hi there,

I have a project in Godot 3.0.6 that uses a GDNative C++ DLL. Once exported, the Godot .exe and GDNative .dll are in the same output folder and the game runs with no issues. (However I do get a WARNING: No Directory “Res://” in the console, but the game functions correctly).

Once I zip and copy the game over to any other PC (Win 7, 10) it says that it cannot load my GDNative DLL with the following message:


ERROR: Can’t open dynamic link library: mygdnativetest.dll. Error: Error 126: The specified module could not be found.
platform/windows/os_windows.cpp:1700

ERROR: get_symbol: No valid library handle, can’t get symbol from GDNative object
modules/gdnative/gdnative.cpp:317

ERROR: ini_library: No nativescript_init in “res://mygdnativetest.dll” found
modules/gdnative/nativescript/nativescript.cpp:1054

WARNING: No directory “res://”
WARNING: No directory “res://”


Can anyone please point me in the right direction as to what the problem could be? Is there perhaps a flag or something missing in the SConstruct file? It is very strange that the games runs locally but not when copied and run on another PC.

Thanks!

Does the “any other PC” use NTFS for it’s file system?

guppy42 | 2018-10-11 12:36

Sorry yes by “any other PC” they are NTFS file system, tried on both Windows 7 and 10.

upperclasslemon | 2018-10-11 12:49

NTFS is (iirc) casesensitive, where as FAT32 is not so if the original computer does not use NTFS it could well be the case the the filename is not in all lower case in the file system.

guppy42 | 2018-10-12 04:13

Hi guppy42, thanks for the suggestion. I can confirm that the DLL is the same lowercase from SConstruct GDNative dll build to the exported build.

I have tested this on the latest Godot Master Branch with NativeScript 1.1 and same isssue. Exported game runs fine on local pc but same error 126 on other PCs.

upperclasslemon | 2018-10-15 14:06

@upperclasslemon Did you find out what the problem was? I’m having the exact same problem and don’t want to start a new thread.

VinnieH01 | 2020-02-09 18:06

also having the same problem. DenverCoder9, what happened to you?

Wavesonics | 2020-06-03 02:06

Any update? I’m having the same problem. For me it works on Linux but not on Windows.

Aaron Franke | 2021-04-21 04:24

I’m having the same issue as well. It’s been almost three years and not suggestions of a solution for this problem?

XeroWolf | 2021-06-22 17:11

:bust_in_silhouette: Reply From: Wavesonics

I think I know what the problem was, at least in my case.

My DLL relied on another DLL implicitly. It was the Microsoft Visual C++ runtime DLL, something like msvcr140.dll or what ever.

I had had that installed on my system, but some people I sent my game to did not.

The problem being that the error message Godot gives is a bit misleading. It’s not that YOUR dll isn’t found, it’s that your dll failed to load because the other dll it required was not found. But the error handling just reports your dll as not found if it fails to load for any reason.

To solve this I did the following:
Remember that DLL resolution starts by looking in the current working directory for the executable trying to load the DLL, if it is not found there, then it looks in the system directory.

So since I didn’t want to send an installer to my users which would put the dll in their system directory, I simply shipped the msvcr dll along side the exe so that it would be found at the first stage of resolution.

I simply shipped the msvcr dll along side the exe so that it would be found at the first stage of resolution.

While this works, note that the MSVC redistributable EULA doesn’t allow you to do this. Instead, you’re supposed to bundle the installer and run it (possibly in an unattended manner using command line arguments).

It’s kind of a mystery as to why the MSVC redistributable isn’t being installed via Windows Update automatically, but that’s how things are.

Calinou | 2021-06-25 23:02

Ha, that I did not know. Thanks Microsoft, I hate it

Wavesonics | 2021-06-26 01:21