Skip to content

GDNative does not work for Windows from Linux at all #3463

@diocore

Description

@diocore

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:

  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

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:

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.

  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

  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.

URL to the documentation page:
https://docs.godotengine.org/en/3.2/tutorials/plugins/gdnative/gdnative-cpp-example.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:manualIssues and PRs related to the Manual/Tutorials section of the documentationbug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions