+1 vote

I've created a native C++ plugin with the Godot toolkit and I'm getting errors loading the DLL:

ERROR: Can't open dynamic library: D:/samples/godot/godot-unofficial-demo-projects-v3/td2/bin/libclipper.dll. Error: Error 193: %1 is not a valid Win32 application.
At: platform\windows\os_windows.cpp:1687
ERROR: GDNative::get_symbol: No valid library handle, can't get symbol from GDNative object
At: modules\gdnative\gdnative.cpp:315
ERROR: NativeScriptLanguage::init_library: No nativescript_init in "res://bin/libclipper.dll" found
At: modules\gdnative\nativescript\nativescript.cpp:1054

This is Godot V3.0.2 64 bit so why it talking about 32 bit application?
I can see with dependency walker that godotnativescriptinit is present, so it's not finding it for some reason.

All I did is switch the C sample to C++ and put extern "C" on three functions


So what am I doing wrong?

in Engine by (238 points)

I encountered the exact same problem. I think it was related to compiler settings. I can try to find the problem later today.

Edit: I can't seem to reproduce it, sorry.

1 Answer

+3 votes

I tried again on a different machine - this time I used a different version of vcvarsall.bat to setup Visual Studio for C++ compilation.


Now it runs just fine and I'm not seeing the errors I did before!

by (238 points)

hello, i'm running in the same problem...
is it the file you are talking about?
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat ?

just tried and it worked!!! thanks a thousand times for this post!

you really help me a lot.the same error and use your methoid now i cam compile successfully. and i find that the original vcvars is x86_64, and after i used your method it changed to x64, , so i guess this is the erroe caused by win32 or x86? hoping someone can find the real reason of this. thanks again.

Yes, this works. You need to run the Visual Studio Developer Command Prompt, go to the folder containing vcvars64.bat and run it. In my case, the folder was:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat

Then compile and link simple.c as found in the instructions.

Also make sure that your simple.gdns class name is all caps: SIMPLE. Any lower case letters made it not work for me.

Note that using the other Visual Studio command prompts (for example, x64 Native Tools Command Prompt), as suggested by the Visual Studio website, didn't work for me.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.