GameAnalytics / GA-SDK-GODOT

Official GameAnalytics Godot SDK repository
MIT License
42 stars 7 forks source link

Module cannot be compiled into Godot with Mingw64 #7

Closed superoven closed 3 years ago

superoven commented 3 years ago

In order to build windows export templates on any machine that isn't a windows machine, one needs to use mingw64: https://docs.godotengine.org/en/stable/development/compiling/compiling_for_windows.html#creating-windows-export-templates https://gameanalytics.com/docs/item/godot-sdk

Mingw64 version:

$ x86_64-w64-mingw32-g++ --version
x86_64-w64-mingw32-g++ (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When building on Godot 3.2.3-stable:

$ scons platform=windows tools=no target=release_debug bits=64 use_mingw=yes verbose=yes -j6

It will fail on the step that actually links the GameAnalytics.lib file to the binary.

This is the command it fails on in the verbose logs:

$ x86_64-w64-mingw32-g++ -o bin/godot.windows.opt.debug.64.exe -static -Wl,--stack,8388608 GameAnalytics.lib platform/windows/godot_windows.windows.opt.debug.64.o platform/windows/context_gl_windows.windows.opt.debug.64.o platform/windows/crash_handler_windows.windows.opt.debug.64.o platform/windows/os_windows.windows.opt.debug.64.o platform/windows/key_mapping_windows.windows.opt.debug.64.o platform/windows/joypad_windows.windows.opt.debug.64.o platform/windows/power_windows.windows.opt.debug.64.o platform/windows/windows_terminal_logger.windows.opt.debug.64.o platform/windows/godot_res.windows.opt.debug.64.o -Lmodules/gameanalytics/cpp/lib/win64 main/libmain.windows.opt.debug.64.a modules/libmodules.windows.opt.debug.64.a platform/libplatform.windows.opt.debug.64.a drivers/libdrivers.windows.opt.debug.64.a scene/libscene.windows.opt.debug.64.a servers/libservers.windows.opt.debug.64.a core/libcore.windows.opt.debug.64.a modules/freetype/libfreetype_builtin.windows.opt.debug.64.a -lmingw32 -lopengl32 -ldsound -lole32 -ld3d9 -lwinmm -lgdi32 -liphlpapi -lshlwapi -lwsock32 -lws2_32 -lkernel32 -loleaut32 -ldinput8 -ldxguid -lksuser -limm32 -lbcrypt -lavrt -luuid -ldwmapi

It fails with this error:

x86_64-w64-mingw32-g++: error: GameAnalytics.lib: No such file or directory

If one attempts to directly reference GameAnalytics.lib with ${GODOT_ROOT}/modules/gameanalytics/cpp/lib/win64/GameAnalytics.lib in the previous command instead, you get this error:

$ x86_64-w64-mingw32-g++ -o bin/godot.windows.opt.debug.64.exe -static -Wl,--stack,8388608 modules/gameanalytics/cpp/lib/win64/GameAnalytics.lib platform/windows/godot_windows.windows.opt.debug.64.o platform/windows/context_gl_windows.windows.opt.debug.64.o platform/windows/crash_handler_windows.windows.opt.debug.64.o platform/windows/os_windows.windows.opt.debug.64.o platform/windows/key_mapping_windows.windows.opt.debug.64.o platform/windows/joypad_windows.windows.opt.debug.64.o platform/windows/power_windows.windows.opt.debug.64.o platform/windows/windows_terminal_logger.windows.opt.debug.64.o platform/windows/godot_res.windows.opt.debug.64.o -Lmodules/gameanalytics/cpp/lib/win64 main/libmain.windows.opt.debug.64.a modules/libmodules.windows.opt.debug.64.a platform/libplatform.windows.opt.debug.64.a drivers/libdrivers.windows.opt.debug.64.a scene/libscene.windows.opt.debug.64.a servers/libservers.windows.opt.debug.64.a core/libcore.windows.opt.debug.64.a modules/freetype/libfreetype_builtin.windows.opt.debug.64.a -lmingw32 -lopengl32 -ldsound -lole32 -ld3d9 -lwinmm -lgdi32 -liphlpapi -lshlwapi -lwsock32 -lws2_32 -lkernel32 -loleaut32 -ldinput8 -ldxguid -lksuser -limm32 -lbcrypt -lavrt -luuid -ldwmapi
/usr/local/Cellar/mingw-w64/8.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: modules/libmodules.windows.opt.debug.64.a(GameAnalytics.windows.opt.debug.64.o): in function `GameAnalytics::isRemoteConfigsReady()':
/Users/taylor/git/godot/godot/modules/gameanalytics/GameAnalytics.cpp:753: undefined reference to `isRemoteConfigsReady'
/usr/local/Cellar/mingw-w64/8.0.0/toolchain-x86_64/bin/x86_64-w64-mingw32-ld: modules/libmodules.windows.opt.debug.64.a(GameAnalytics.windows.opt.debug.64.o): in function `GameAnalytics::getRemoteConfigsContentAsString()':
...

Where it basically is unable to link the GameAnalytics.lib file.

Thinking this was an issue with me trying to build on Mac, I tried the same procedure on Windows, also using mingw64 to compile the windows build template and got the same error from scons.

I was able to successfully compile the export template when using MVSC 2019 on Windows, so I am fairly confident that is the issue is specifically with attempting to build the export templates with mingw64. This is important for making a build process that does not span multiple machines.

Could we get built .lib and .dll files for the windows export template that would link properly with building godot with mingw64?

the1schwartz commented 3 years ago

I have fixed that now in the latest version now (v1.2.1) and I have tested it as well compiling with Mingw. Let me know if it still doesn't work for you.

the1schwartz commented 3 years ago

Just remember to add the use_mingw=yes parameter for it to work also described here: https://gameanalytics.com/docs/item/godot-sdk#windows