Open TheFamousRat opened 4 years ago
I have the same error in OSX 10.14.6
E 0:00:00:0589 Can't resolve symbol godot_gdnative_init. Error: dlsym(0x7fcc5c43abf0, godot_gdnative_init): symbol not found
E 0:00:00:0589 Failed to obtain godot_gdnative_init symbol
E 0:00:00:0589 No valid library handle, can't get symbol from GDNative object
E 0:00:00:0589 No nativescript_init in "res://bin/osx/libgdexample.dylib" found
Also I compiled changing the src folder path instead of beside to inside the project "/demo" directory contrary to what the documentation says, other way I couln't compile.
Similar, Godot 3.1.2, Manjaro 4.19
E 0:00:00:0257 Can't resolve symbol godot_gdnative_init. Error: /home/biip/Documents/Projects/test/demo/bin/x11/libgdexample.so: undefined symbol: godot_gdnative_init
E 0:00:00:0257 Failed to obtain godot_gdnative_init symbol
E 0:00:00:0257 No valid library handle, can't get symbol from GDNative object
E 0:00:00:0257 No nativescript_init in "res://bin/x11/libgdexample.so" found
Not sure why the symbol is missing, but here's a few possibilities to try:
godot_gdnative_init
marked extern "C"
?symbol_prefix
. For example, use test_
if you renamed the function to test_gdnative_init
.nm
command (on both Linux and Mac OS) lists all the symbols in a binary. Does the function show up if you do nm <your compiled .so/.dylib> | grep gdnative
?Man this is so strange. I removed the project and started for scratch. And now it works for some reason. I've already done this 3 times, so I'm not sure why it's suddenly working.
I repeated the process one more time to see if I could replicate the errors. But still works just fine.
@sheepandshepherd No changes - it's all copy/paste from the documentation.
This is actually more or less just a summary of the documentation - which worked for me:
mkdir gdnative_cpp_example
cd gdnative_cpp_example
git clone --recursive https://github.com/GodotNativeTools/godot-cpp
(worked with both master
-branch and 3.1
-branch)cd godot-cpp
scons platform=linux generate_bindings=yes bits=64
mkdir gdnative_cpp_example/src
src
add new files gdexample.h
, gdexample.cpp
and gdlibrary.cpp
. See doc for sorucegdnative_cpp_example/demo/
bin
folder inside demo
: mkdir gdnative_cpp_example/demo/bin
gdexample.gdns
and gdexample.gdnlib
inside bin
. See doc for sourcegdnative_cpp_example
run scons platform=x11
gdexample.gdns
(As described at the end of this paragraph)File/folder layout looks like:
gdnative_cpp_example
|-- demo
| |-- bin
| |-- gdexample.gdnlib
| |-- gdexample.gdns
|
|-- godot-cpp
|-- src
| |-- gdexample.h
| |-- gdlibrary.cpp
| |-- gdlibrary.cpp
|
|-- SConstruct
Here is a ZIP of the files - except for godot-cpp. Perhaps @TheFamousRat could make a file compare to see if there is any differences: godot3.1-stable_gdnative_cpp_test.zip
@FilipLundby, Thanks a lot for your comment. I did indeed try to redo everything from scratch and it worked too. However I may have found the culprit. It seems as though Godot doesn't like it when the the binaries aren't located precisely in the "res://bin/x11" folder, and also has the same reaction when the .gdns and .gdnlib files aren't located in the "res://bin" folder.
Here's my current project file tree : ├── bin │ ├── gdexample.gdnlib │ ├── gdexample.gdns │ └── x11 │ └── libgdexample.so ├── default_env.tres ├── icon.png ├── icon.png.import ├── Node │ ├── Node.tscn │ └── src │ ├── gdexample.cpp │ ├── gdexample.h │ ├── gdexample.os │ ├── gdlibrary.cpp │ ├── gdlibrary.os │ └── SConstruct └── project.godot
I also naturally modified the paths in SConstruct accordingly. Hope this helps.
They can be anywhere in the project. Godot uses file paths to reference resources inside other resources, so just make sure to update those references:
.gdns
references the .gdnlib
.gdnlib
references the binariesSConstruct
determines where the binaries are built
Hello, I've been following exactly this https://docs.godotengine.org/en/3.1/tutorials/plugins/gdnative/gdnative-cpp-example.html C++ Gdnative tutorial. Back when I was using Windows 10 it worked fine, but now I am on Ubuntu 18.04 and it doesn't work. The code (exactly the one used in the tutorial) compiles without any problem; however, when I try to import the libs into Godot, I get those errors :
Can't resolve symbol godot_gdnative_init. Error: /home/thefamousrat/Documents/Godot/test/src/bin/x11/libgdexample.so: undefined symbol: godot_gdnative_init modules/gdnative/gdnative.cpp:347 - Failed to obtain godot_gdnative_init symbol modules/gdnative/gdnative.cpp:488 - No valid library handle, can't get symbol from GDNative object modules/gdnative/nativescript/nativescript.cpp:1504 - No nativescript_init in "res://src/bin/x11/libgdexample.so" found
Anyone has any inputs on this ? I've seen this error pop up for other persons on Linux. I'm using Godot 3.1.2 and the latest Godot-cpp/godot_headers repos (I tried using the nativescript-1.1 branch, but to no avail).
Thank you