Open diocore opened 4 years ago
I think the problem is that the instructions were written for Visual C++, not MINGW which indeed requires different switches.
I don't use MINGW so I don't know what it should have as switches but looking at the SConstruct file of Godot-cpp we might find some clues:
# MinGW
if env['bits'] == '64':
env['CXX'] = 'x86_64-w64-mingw32-g++'
elif env['bits'] == '32':
env['CXX'] = 'i686-w64-mingw32-g++'
env.Append(CCFLAGS=['-g', '-O3', '-std=c++14', '-Wwrite-strings'])
env.Append(LINKFLAGS=['--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++'])
I think the -Wwrite-strings
might have something to do with making sure symbols are properly exported?
that could probably work. My main issue is that even if I build the files, which are built correctly afaik (checked with a dll checker) that I can't get it to work with these files and gdnative libs. Godot says it is missing init_library() and there is no example in the docs. I'd really like to see it run at least once so I could test what the problem is. Could you provide a .dll file for godot, so I can test it in my project maybe?
Your Godot version: 3.2 Issue description: Hi, okay, I've got a couple of issues here: first of the SConstruct file does not work for 3 reasons:
scons platform=windows generate_bindings=yes use_mingw=yes bits=64
this is maybe because the flags are for the MSVC and not for mingw but according to the documentation and in order to be able to cross compile from linux to windows mingw should be used.
after fixing this editing the SConstruct so it is forced to use mingw by adding:
it uses mingw and has no problems anymore with the flags.
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:
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:After creating the gdnativelibrary.gdnlib and the nativescript.gdns as described in the documentation I get the following error upon execution:
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.
URL to the documentation page: https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html