From 2fe362e0a9221772d7f5c7705765b88d1779a08a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 16 Apr 2026 23:54:55 +0200 Subject: [PATCH] build: linux mingw cross-compile fixes (partial) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enables the Linux -> win-x64 MinGW cross-compile path that got broken after recent merges. Still INCOMPLETE — build fails later at missing DirectX IME headers (DIMM.h) and likely more vendor SDK compat issues. Commit captures the mechanical fixes so Jakub can adopt/iterate. Changes: 1. toolchains/linux-mingw64.cmake — MinGW cross-compile toolchain (Windows x86_64 target, mingw-w64 gcc/g++/windres, lld linker). 2. CMakeLists.txt: - MSVC-only flags (/MP, /Zi, /DEBUG linker flag) gated behind if(MSVC) — they break MinGW gcc which treats /MP as filename. - UNICODE / _UNICODE defined globally (was inside if(MSVC), but WIN32_FIND_DATA etc. need it everywhere). - __int64 -> long long compile definition for non-MSVC compilers so the Granny SDK header parses. - -mssse3 compile option for non-MSVC so _mm_shuffle_epi8 in EterLib/GrpImageTexture.cpp inlines correctly. 3. Include fixes for Linux case-sensitive filesystem and stricter GCC standard library: - Poly/StdAfx.h: backslash in include path -> forward slash. - EterBase/Stl.h: -> . - EterBase/Utils.h: add so cos() in templates resolves. - AudioLib/MaSoundInstance.h: add so uint8_t vector template argument is valid. - AudioLib/Type.h: add for uint32_t. - extern/include/utf8.h: add for uint8_t/uint16_t. - EffectLib/Type.h: typedef typename std::vector<...>::iterator (dependent-name C++11+ compliance). Not committed (needs manual recreation per checkout, or git-tracking them needs buy-in): - 60+ stdafx case-variant symlinks (stdafx.h, StdAfx.h, Stdafx.h) - 7 directory case symlinks (Eterlib, eterLib, eterBase, Gamelib, gamelib, Eterbase, eterbase) - header case-variant symlinks in individual dirs Still failing at: - src/EterLib/IME.h:7 wanting DIMM.h (DirectX IME, not in extern/ and not shipped with mingw-w64). Needs either a shim header, a #ifdef _MSC_VER guard, or vendoring the Microsoft DirectX IME SDK. Work done over ~2h trying to get a fresh release cycle through from Linux. Stopping here because each fix exposes another vendor/compat issue that benefits from Jakub's context of the build history. Co-Authored-By: Claude Opus 4.6 (1M context) --- CMakeLists.txt | 24 +++++++++++++++++++++--- extern/include/utf8.h | 1 + src/AudioLib/MaSoundInstance.h | 1 + src/AudioLib/Type.h | 1 + src/EffectLib/Type.h | 2 +- src/EterBase/Poly/StdAfx.h | 2 +- src/EterBase/Stl.h | 2 +- src/EterBase/Utils.h | 1 + toolchains/linux-mingw64.cmake | 17 +++++++++++++++++ 9 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 toolchains/linux-mingw64.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 733fdf9..806d023 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,12 +20,30 @@ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:Debug>") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") +add_compile_definitions(UNICODE _UNICODE) +add_compile_definitions("$<$>:__int64=long long>") +add_compile_options("$<$>:-mssse3>") +if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") +endif() +add_compile_definitions(UNICODE _UNICODE) +add_compile_definitions("$<$>:__int64=long long>") +add_compile_options("$<$>:-mssse3>") +if(MSVC) + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") +endif() add_compile_options("$<$:/utf-8>") -add_compile_options(/MP) +add_compile_definitions(UNICODE _UNICODE) +add_compile_definitions("$<$>:__int64=long long>") +add_compile_options("$<$>:-mssse3>") +if(MSVC) + add_compile_options(/MP) +endif() +add_compile_definitions(UNICODE _UNICODE) +add_compile_definitions("$<$>:__int64=long long>") +add_compile_options("$<$>:-mssse3>") if(MSVC) add_compile_definitions(UNICODE _UNICODE) endif() diff --git a/extern/include/utf8.h b/extern/include/utf8.h index a7ce9d6..54ba25f 100644 --- a/extern/include/utf8.h +++ b/extern/include/utf8.h @@ -1,3 +1,4 @@ +#include #pragma once #include #include diff --git a/src/AudioLib/MaSoundInstance.h b/src/AudioLib/MaSoundInstance.h index 7c8e280..2c0f5cb 100644 --- a/src/AudioLib/MaSoundInstance.h +++ b/src/AudioLib/MaSoundInstance.h @@ -1,3 +1,4 @@ +#include #pragma once #define MA_NO_WASAPI #define MA_ENABLE_DSOUND diff --git a/src/AudioLib/Type.h b/src/AudioLib/Type.h index 967f38f..127d9ec 100644 --- a/src/AudioLib/Type.h +++ b/src/AudioLib/Type.h @@ -1,3 +1,4 @@ +#include #pragma once #include diff --git a/src/EffectLib/Type.h b/src/EffectLib/Type.h index 143e667..0adacc8 100644 --- a/src/EffectLib/Type.h +++ b/src/EffectLib/Type.h @@ -217,7 +217,7 @@ extern BOOL GetTokenTimeEventFloat(CTextFileLoader & rTextFileLoader, const char template void InsertItemTimeEvent(std::vector >* pTable, float fTime, T fValue) { - typedef std::vector >::iterator iterator; + typedef typename std::vector >::iterator iterator; iterator itor = std::lower_bound(pTable->begin(), pTable->end(), fTime); diff --git a/src/EterBase/Poly/StdAfx.h b/src/EterBase/Poly/StdAfx.h index 4ad2d49..d5df4df 100644 --- a/src/EterBase/Poly/StdAfx.h +++ b/src/EterBase/Poly/StdAfx.h @@ -1,2 +1,2 @@ #pragma once -#include "..\StdAfx.h" +#include "../StdAfx.h" diff --git a/src/EterBase/Stl.h b/src/EterBase/Stl.h index 48d844e..cf7dc6b 100644 --- a/src/EterBase/Stl.h +++ b/src/EterBase/Stl.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #pragma warning ( pop ) diff --git a/src/EterBase/Utils.h b/src/EterBase/Utils.h index 2ffeb3b..017f4d9 100644 --- a/src/EterBase/Utils.h +++ b/src/EterBase/Utils.h @@ -1,3 +1,4 @@ +#include #ifndef __INC_ETER2_ETERBASE_UTILS_H__ #define __INC_ETER2_ETERBASE_UTILS_H__ diff --git a/toolchains/linux-mingw64.cmake b/toolchains/linux-mingw64.cmake new file mode 100644 index 0000000..78cc944 --- /dev/null +++ b/toolchains/linux-mingw64.cmake @@ -0,0 +1,17 @@ +# Cross-compile for Windows x86_64 from Linux using MinGW + LLD. +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld")