Skip to content

[tools/windows.py] misplaced flag prevents gd-extensions with C files to build #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dfred opened this issue Nov 2, 2022 · 1 comment · Fixed by #908
Closed

[tools/windows.py] misplaced flag prevents gd-extensions with C files to build #906

Dfred opened this issue Nov 2, 2022 · 1 comment · Fixed by #908

Comments

@Dfred
Copy link

Dfred commented Nov 2, 2022

TL;DR

In https://github.com/godotengine/godot-cpp/blame/master/tools/windows.py#L43 -std=c++17 is set to CCFLAGS but should be set to CXXFLAGS as this prevents compilation of gd-extensions with .c files.

Background

I've been trying to use godot-sqlite's gd-extension branch with Godot4-beta3, which has godot-cpp as a submodule set to SHA 1044251.
However Godot4-beta3.exe currently fails to load the artifact built from Github actions, libgdsqlite.windows.template_debug.x86_64.dll, because of links with debug versions of VcRedist DLLs - for which I submitted issue 102.

So I've been building the sqlite gd-extension with MinGW-w64 but got trapped in DLL dependency hell. Eventually I found another pre-built toolchain / package that worked: LLVM-MinGW .

Godot-sqlite builds src/sqlite/shell.c and src/sqlite/sqlite3.c along with src/gdsqlite.cpp and src/register_types.cpp, yet that fails because scons calls:

gcc -o src\sqlite\sqlite3.o -c -std=c++17 -O2 -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -Igodot-cpp\godot-headers -Igodot-cpp\include -Igodot-cpp\gen\include -Isrc src\sqlite\sqlite3.c
=====
error: invalid argument '-std=c++17' not allowed with 'C'

=====
scons: *** [src\sqlite\sqlite3.o] Error 1
scons: building terminated because of errors.

I tracked down the std flag to tools/windows.py and fixed the error by changing line 43 to env.Append(CXXFLAGS=["-std=c++17"]).
Then that compiled the gd-extension's dll, which loads flawlessly in Godo4-beta3 editor under Windows 10.

@Faless I hope this helps.

@Dfred Dfred changed the title [tools/windows.py] misplaced flag prevents gd-extensions to build on Windows + Mingw64 (LLVM) [tools/windows.py] misplaced flag prevents gd-extensions with C files to build Nov 2, 2022
@Faless
Copy link
Contributor

Faless commented Nov 2, 2022

@Dfred thanks for looking into this, I've opened #908 as a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants