godot
godot copied to clipboard
Error cross-compiling for Windows from Ubuntu
Godot version
4.0
System information
Ubuntu 20.04.5
Issue description
Error when cross compiling for Windows from Ubuntu:
Received error:
Detected mingw version is not using posix threads. Only posix version of mingw is supported. Use "update-alternatives --config <platform>-w64-mingw32-[gcc|g++]" to switch to posix threads.
After running the command to switch to posix threads tried to compile:
$scons platform=windows
scons: Reading SConscript files ...
Auto-detected 4 CPU cores available for build parallelism. Using 4 cores by default. You can override it with the -j argument.
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
[ 96%] Compiling platform/windows/os_windows.cpp ...
[100%] progress_finish(["progress_finish"], [])
[100%] platform/windows/os_windows.cpp: In member function 'DWRITE_FONT_WEIGHT OS_Windows::_weight_to_dw(int) const':
platform/windows/os_windows.cpp:933:10: error: 'DWRITE_FONT_WEIGHT_SEMI_LIGHT' was not declared in this scope; did you mean 'DWRITE_FONT_WEIGHT_SEMI_BOLD'?
933 | return DWRITE_FONT_WEIGHT_SEMI_LIGHT;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| DWRITE_FONT_WEIGHT_SEMI_BOLD
scons: *** [platform/windows/os_windows.windows.editor.x86_64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:05:28.743]
Steps to reproduce
sudo apt-get install mingw-w64
scons platform=windows
update-alternatives --config x86_64-w64-mingw32-gcc
update-alternatives --config x86_64-w64-mingw32-g++
scons platform=windows
Minimal reproduction project
This was from a fresh clone on master.
The mingw headers version on Ubuntu 20.04 is likely too old. I'll see if we can work it around by defining the values ourselves, but otherwise upgrading to a new distro/mingw should solve it.
These commands are wrong:
update-alternatives --config x64_86-w64-mingw32-gcc
update-alternatives --config x64_86-w64-mingw32-g++
They must be:
update-alternatives --config x86_64-w64-mingw32-gcc
update-alternatives --config x86_64-w64-mingw32-g++
You need mingw-w64 v8.0.0 because the related enum added in this version. Godot compiles on Ubuntu 22.04 without any error(mingw-w64 version: 8.0.0-1)
Whoops, I typed the commands wrong in my post. Fixing my OP.
@nbstrong Could you try this patch and see if it's sufficient to build Godot 4.0 with your mingw version?
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 91d2d1e996..5719b856d8 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -74,6 +74,11 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#define GetProcAddress (void *)GetProcAddress
#endif
+// Workaround for MinGW headers before 8.0.
+#ifndef DWRITE_FONT_WEIGHT_SEMI_LIGHT
+#define DWRITE_FONT_WEIGHT_SEMI_LIGHT 350
+#endif
+
static String format_error_message(DWORD id) {
LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
@akien-mga Unfortunately, I already upgraded Ubuntu to 22.10. Upgrading did resolve my issue, though.
No problem, I set up an Ubuntu 20.04 podman container to reproduce and fix the issue :+1: