godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.76k stars 3.06k forks source link

Revision of the SConstruct file provided at "GDNative C++ example" #3304

Open danielvmacedo opened 4 years ago

danielvmacedo commented 4 years ago

I think the tutorial at https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html have a problem in the section "Compiling the plugin". The SConstruct file provided is giving me linking problems also reported by this user: https://godotengine.org/qa/64822/trouble-with-the-gdnative-c-example-from-the-documentation

However, I got it working using a modified version of the SConstruct file provided by this project: https://github.com/ProggerParrot/Godot-CppProject-Template

Best Regards,

Daniel

jumpy88 commented 4 years ago

Hello @danielvmacedo, you could also be interested in this other issue.

PGrad-zz commented 4 years ago

@danielvmacedo I had the same issue, and I found that if I did a scons build from the "x64 Native Tools Command Prompt for VS2019" the link errors went away.

You see, the issue is with cl.exe itself. There are different builds of cl.exe for different architectures: x86, arm, x64 etc. I found that if I did "where cl.exe" in my prompt window I had a x86 build of cl.exe. But the gdnative examples are built for x64. I believe that if you build with x86 cl.exe you get different mangled signatures for functions than if you link with x64 cl.exe, and this causes link errors.

Try using the x64 native tools prompt and see if that resolves the issue.

akien-mga commented 1 year ago

It's also lacking support for ARM64 for macOS.

We should generally avoid including full scripts in the documentation as they tend to grow stable. We should link to those scripts on properly maintained and branched Git repositories (demos, etc.).

For this tutorial, the SConstruct in https://github.com/godotengine/godot-cpp/tree/3.x can be used as a reference.