godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

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

Open danielvmacedo opened this issue 4 years ago • 3 comments

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

danielvmacedo avatar Mar 25 '20 02:03 danielvmacedo

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

jumpy88 avatar Apr 11 '20 08:04 jumpy88

@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.

PGrad-zz avatar Apr 20 '20 02:04 PGrad-zz

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.

akien-mga avatar Feb 23 '23 23:02 akien-mga