BastiaanOlij / gdnative_cpp_example

GDNative C++ example for tutorial
MIT License
65 stars 31 forks source link

gdnative does not work on windows at all #8

Closed diocore closed 4 years ago

diocore commented 4 years ago

Hi, okay, I've got a couple of issues here: first of the SConstruct file does not work for 3 reasons:

  1. The flags for the c compilation don't exist. I changed them to the once recommended from my console. image after fixing this scons uses g++ instead of mingw even though I did all steps to ensure the usage of mingw as written in the documentation. this is the line I use for compilation: scons platform=windows generate_bindings=yes use_mingw=yes bits=64

after fixing this editing the SConstruct so it is forced to use mingw by adding:

env = Environment(tools = ['mingw'])
env.Replace(CXX='/usr/bin/x86_64-w64-mingw32-g++',
            LINK='/usr/bin/x86_64-w64-mingw32-g++')

it uses mingw and has no problems anymore with the flags. but now lets move on to the next reason.

  1. scons successfully builds using mingw and uses all the right flags and all and puts a .so file in demo/bin/win64. Yeaj an .so file.... with the platform chosen for windows and compilation with Why? probably because the SConstruct is wrong again. Console output:
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    /usr/bin/x86_64-w64-mingw32-g++ -DEBUG -shared -o demo/bin/win64/libgdexample.so src/gdexample.o src/gdlibrary.o -Lgodot-cpp/bin -lgodot-cpp.windows.debug.64 -Wl,--out-implib,demo/bin/win64/libgdexample.a
    scons: done building targets.

    which clearly states -o demo/bin/win64/libgdexample.so so after renaming the file ending to .dll and checking it with a dll checker, everything seems fine: image

so lets move to the next problem

  1. After creating the gdnativelibrary.gdnlib and the nativescript.gdns as described in the documentation I get the following error upon execution: image

so... at this point and after so many errors in the files and building process I'm at a point at which I wonder if I'm doing something totally wrong or If it had ever been tested by someone before posting it...

I even wanted to try the complete example which is referenced here https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html at the end of the introduction just to check whether or not it worked if someone else built the dynamic libraries just to find out that there are not libraries pre-build to test it.

I hope someone can help me because gdnative libraries is a part of my bachelor thesis, or to put it in another way I want to use it to demonstrate my bachelor thesis as well as in a game I'm building.

diocore commented 4 years ago

I posted this in the official repository: https://github.com/godotengine/godot-docs/issues/3463

so I guess I can close this one now