0 votes

Hello everyone.

I've been working through the GDNative C example tutorial in the documentation and I'm having trouble compiling the module. I am using a Windows computer and MinGW-W64 (msys2). I'm new to GCC, and DLLs in general, so please forgive me if this is a stupid question.
The -rdynamic option isn't recognized in this environment, and trying to compile with that option fails, so I tried to use -Wl,--export-all-symbols instead. There are no errors after that, however, when I run the project and click the button, I get the error "Invalid call. Nonexistent function 'get_data' in base 'NativeScript".
These are the exact commands that I have used to compile the project:

gcc -std=c11 -fPIC -c -I../godot_headers simple.c -o simple.o

gcc -Wl,--export-all-symbols -shared simple.o -o ../simple/bin/libsimple.dll

What could be going wrong here?

Godot version 3.3.2
in Engine by (12 points)

1 Answer

+1 vote

Disclaimer: I have no idea what I'm doing :D

Just leaving out -rdynamic, with the rest of the commands identical to the docs works for me.

Looking at https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Link-Options.html#Link-Options it seems to me that this option is not for windows ("on platforms that support it").

From this stack overflow https://stackoverflow.com/questions/36692315/what-exactly-does-rdynamic-do-and-when-exactly-is-it-needed I gather that it is more for executables than for libraries.

by (1,517 points)

I got it working!
You are correct that leaving out both -rdynamic and -Wl,--export-all-symbols seems to work just fine on Windows.

The problem was actually in my main.gd script and had nothing to do with my compilation steps. All this time I thought that the symbols weren't getting exported correctly because I was using some wrong combination of options on the command line. I feel so embarrassed right now. Thank you so very much for the help though! I really appreciate it.

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 Frequently asked questions and 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 [email protected] with your username.