samsface / godot-native-example

Example Godot native project using cmake
MIT License
32 stars 11 forks source link

How do you properly export the example project? #5

Open DrBoontis opened 2 years ago

DrBoontis commented 2 years ago

Hello. I'm back again, this time with a non-duplicate issue. I now know how to check the closed issues before submitting my own (lol).

I'm not aware of any kind of special procedure for exporting with GDNative, so I simply used the traditional 'Project > Export' method in the Godot editor. The project works as intended on my computer, but when I send it to my friend's they get this error instead:

ERROR: Can't open dynamic library: addons/example/gdnative-example.dll, error: Error 126: The specified module could not be found.
.
   at: (platform/windows/os_windows.cpp:2353)
ERROR: No valid library handle, can't get symbol from GDNative object
   at: get_symbol (modules/gdnative/gdnative.cpp:510)
ERROR: No nativescript_init in "res://addons/example/gdnative-example.dll" found
   at: init_library (modules/gdnative/nativescript/nativescript.cpp:1510)
ERROR: Error opening file 'res://icon.png'.
   at: load_image (core/io/image_loader.cpp:55)
SCRIPT ERROR: Attempt to call function 'new' in base 'NativeScript' on a null instance.
          at: _ready (res://example.gdc:5)

Despite what the error says, the .dll is clearly in that directory. I found a similar issue and what I think is happening is the .dll isn't able to load because of dependencies available on my machine, but not on others'. Here's a list of the file's dependencies:

MSVCP140D.dll
VCRUNTIME140D.dll
VCRUNTIME140_1D.dll
ucrtbased.dll
KERNEL32.dll

I saw two other similar issues, but I'm not familiar enough with VS or CMake to know out how to configure these so-called 'flags'. I assume I have to modify either 'CMakeLists.txt' or 'CMakeCache.txt', but I'm not exactly clear on what changes I'm supposed to make.

One of the issues suggested building in release mode, but when I tried that I received a few hundred errors like this one:

godot-cpp.windows.debug.64.lib(String.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Godot.obj

I've been trying to figure this out myself for a few days, but I just feel lost so now I'm asking for help again. I'm sure I'm just missing something very simple like last time.

samsface commented 1 year ago

Looks like you compiled the dll in debug mode. You need to compile it in release mode.

LyffLyff commented 1 year ago

Hello, I have the same problem, my .dll not working on a friends computer. I've tried building it in RELEASE mode but I always get a bunch of errors just like DrBoontis does.

Has anyone found a solution to this?