From 24985073ed4e944276be12b2c35ec503b9d55c12 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 17:20:16 +0000 Subject: [PATCH 01/11] Fix header issues on mingw When cross compiling from Linux, header names are case sensitive unlike on Windows. --- project/include/system/System.h | 2 +- project/src/backend/sdl/SDLWindow.cpp | 2 +- project/src/graphics/opengl/OpenGL.h | 2 +- project/src/system/System.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project/include/system/System.h b/project/include/system/System.h index 63abfd4bb5..10263d30ba 100644 --- a/project/include/system/System.h +++ b/project/include/system/System.h @@ -90,7 +90,7 @@ namespace lime { } -#ifndef HX_WINDOWS +#if !defined(HX_WINDOWS) || defined(__MINGW32__) #include #else diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index e58103f3e6..6e6459f54f 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -6,7 +6,7 @@ #ifdef HX_WINDOWS #include -#include +#include #undef CreateWindow #endif diff --git a/project/src/graphics/opengl/OpenGL.h b/project/src/graphics/opengl/OpenGL.h index 00e9c14adc..e6e426b7ac 100644 --- a/project/src/graphics/opengl/OpenGL.h +++ b/project/src/graphics/opengl/OpenGL.h @@ -76,7 +76,7 @@ //#define LIME_GLES3_API #include #ifndef NATIVE_TOOLKIT_SDL_ANGLE -#include +#include #endif // typedef ptrdiff_t GLsizeiptrARB; diff --git a/project/src/system/System.cpp b/project/src/system/System.cpp index 0c88fb66e2..2875d55e80 100644 --- a/project/src/system/System.cpp +++ b/project/src/system/System.cpp @@ -4,7 +4,7 @@ #include #include #pragma comment(lib, "wbemuuid.lib") -#include +#include #endif #include From 07851c0a5fb45832128e6146bbd6ff893432fd28 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 17:20:18 +0000 Subject: [PATCH 02/11] Remove isfinite define in openal config This causes issues on mingw, and is no longer needed since openal now uses std::isfinite (c++11) instead of isfinite. https://github.com/kcat/openal-soft/commit/3ae1c78d1ac07cd22727296488a399c48597fd15 --- project/lib/custom/openal/include/config-windows-x86.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/project/lib/custom/openal/include/config-windows-x86.h b/project/lib/custom/openal/include/config-windows-x86.h index a8119f812c..762630f90e 100644 --- a/project/lib/custom/openal/include/config-windows-x86.h +++ b/project/lib/custom/openal/include/config-windows-x86.h @@ -12,11 +12,6 @@ #include -#ifndef isfinite - #include - #define isfinite _finite -#endif - /* Define a restrict macro for non-aliased pointers */ #define RESTRICT __restrict From dcece3aef3d8ffe5039ad153b0cd137823b6b193 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 17:20:20 +0000 Subject: [PATCH 03/11] Fix cairo setup for mingw --- project/lib/custom/cairo/configs/windows/config.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/project/lib/custom/cairo/configs/windows/config.h b/project/lib/custom/cairo/configs/windows/config.h index 2d4c5aeabe..2c84212e69 100644 --- a/project/lib/custom/cairo/configs/windows/config.h +++ b/project/lib/custom/cairo/configs/windows/config.h @@ -44,13 +44,15 @@ // #define CAIRO_HAS_DLSYM 1 +#ifdef __MINGW32__ // #define HAVE_BYTESWAP_H 1 // #define HAVE_INTTYPES_H 1 -// #define HAVE_STDINT_H 1 +#define HAVE_STDINT_H 1 // #define HAVE_SYS_INT_TYPES_H 1 // #define HAVE_UNISTD_H 1 // #define HAVE_UINT128_T 1 -// #define HAVE_UINT64_T 1 +#define HAVE_UINT64_T 1 +#endif // #define HAVE_INTEL_ATOMIC_PRIMITIVES 1 From a4ceb0f3a190fbe24cbe8bbd58045d1dfa68af04 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 17:20:21 +0000 Subject: [PATCH 04/11] Fix msvc-specific warning flags on mingw --- project/lib/harfbuzz-files.xml | 4 ++-- project/lib/openal-files.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project/lib/harfbuzz-files.xml b/project/lib/harfbuzz-files.xml index 60625a997c..c65f886921 100644 --- a/project/lib/harfbuzz-files.xml +++ b/project/lib/harfbuzz-files.xml @@ -15,8 +15,8 @@ - - + + diff --git a/project/lib/openal-files.xml b/project/lib/openal-files.xml index 23d61be4f4..0d8a6c181a 100644 --- a/project/lib/openal-files.xml +++ b/project/lib/openal-files.xml @@ -140,7 +140,7 @@ - + From df06b839986c1d23363e6043878d315d38785dad Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 20 Dec 2025 10:46:35 +0000 Subject: [PATCH 05/11] Fix msvc-specific defines on mingw --- project/lib/harfbuzz-files.xml | 4 ++-- project/lib/openal-files.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project/lib/harfbuzz-files.xml b/project/lib/harfbuzz-files.xml index c65f886921..ff25b44e4e 100644 --- a/project/lib/harfbuzz-files.xml +++ b/project/lib/harfbuzz-files.xml @@ -17,8 +17,8 @@ - - + + diff --git a/project/lib/openal-files.xml b/project/lib/openal-files.xml index 0d8a6c181a..7f01ddbcd8 100644 --- a/project/lib/openal-files.xml +++ b/project/lib/openal-files.xml @@ -138,8 +138,8 @@ - - + + From 8741bbde8c41b62d412469290ea5545b0f8b4f3e Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 17:20:22 +0000 Subject: [PATCH 06/11] Enable some missing compiler flags for mingw --- project/lib/openal-files.xml | 17 ++++++----------- project/lib/pixman-files.xml | 10 +++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/project/lib/openal-files.xml b/project/lib/openal-files.xml index 7f01ddbcd8..c81a0eb3cb 100644 --- a/project/lib/openal-files.xml +++ b/project/lib/openal-files.xml @@ -81,6 +81,12 @@ + + + + + +
@@ -100,11 +106,6 @@ - - - - - @@ -118,12 +119,6 @@ - - - - - -
diff --git a/project/lib/pixman-files.xml b/project/lib/pixman-files.xml index 01fb83b21b..52d83e489d 100644 --- a/project/lib/pixman-files.xml +++ b/project/lib/pixman-files.xml @@ -23,11 +23,11 @@ - - - - - + + + + + From 7d098de2a37a45f0facfa1107308b50a367dfd72 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 17:20:23 +0000 Subject: [PATCH 07/11] Fix System.cpp when compiling with mingw With mingw, converting from char* to _bstr_t calls ConvertStringToBSTR which is not defined by mingw. Creating all strings from wchar* avoids this issue. comsuppw.lib is also unavailable on mingw, and we need to add wbemuuid.lib manually as the #pragma comment(lib, ...) in System.cpp is only respected by MSVC. Adding bstr_t explicitly rather than relying on implicit conversion also avoids gcc warnings here. --- project/Build.xml | 3 ++- project/src/system/System.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/project/Build.xml b/project/Build.xml index d6f0d7c857..315a262fa8 100755 --- a/project/Build.xml +++ b/project/Build.xml @@ -434,7 +434,8 @@ - + + diff --git a/project/src/system/System.cpp b/project/src/system/System.cpp index 2875d55e80..06caca2ca3 100644 --- a/project/src/system/System.cpp +++ b/project/src/system/System.cpp @@ -124,7 +124,7 @@ namespace lime { } - hres = pSvc->ExecQuery (bstr_t ("WQL"), query, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); + hres = pSvc->ExecQuery (bstr_t (L"WQL"), query, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); if (FAILED (hres)) { @@ -164,7 +164,7 @@ namespace lime { std::wstring* System::GetDeviceModel () { #if defined (HX_WINDOWS) && !defined (HX_WINRT) - return GetWMIValue (bstr_t ("SELECT * FROM Win32_ComputerSystemProduct"), L"Version"); + return GetWMIValue (bstr_t (L"SELECT * FROM Win32_ComputerSystemProduct"), bstr_t (L"Version")); #endif return NULL; @@ -175,7 +175,7 @@ namespace lime { std::wstring* System::GetDeviceVendor () { #if defined (HX_WINDOWS) && !defined (HX_WINRT) - return GetWMIValue (bstr_t ("SELECT * FROM Win32_ComputerSystemProduct"), L"Vendor"); + return GetWMIValue (bstr_t (L"SELECT * FROM Win32_ComputerSystemProduct"), bstr_t (L"Vendor")); #endif return NULL; @@ -186,7 +186,7 @@ namespace lime { std::wstring* System::GetPlatformLabel () { #if defined (HX_WINDOWS) && !defined (HX_WINRT) - return GetWMIValue (bstr_t ("SELECT * FROM Win32_OperatingSystem"), L"Caption"); + return GetWMIValue (bstr_t (L"SELECT * FROM Win32_OperatingSystem"), bstr_t (L"Caption")); #endif return NULL; @@ -204,7 +204,7 @@ namespace lime { std::wstring* System::GetPlatformVersion () { #if defined (HX_WINDOWS) && !defined (HX_WINRT) - return GetWMIValue (bstr_t ("SELECT * FROM Win32_OperatingSystem"), L"Version"); + return GetWMIValue (bstr_t (L"SELECT * FROM Win32_OperatingSystem"), bstr_t (L"Version")); #endif return NULL; @@ -420,4 +420,4 @@ size_t _mbsrtowcs(wchar_t * ws, const char **src, size_t wn, mbstate_t *st) return -1; } -#endif \ No newline at end of file +#endif From 0993eab5164e3089b5023ec95d07da1c4b1b6844 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 20:34:48 +0000 Subject: [PATCH 08/11] Fix lime rebuild windows with mingw for 64 bit When cross compiling, the default target is set as neko in HXProject, so we can't assume that rebuild will always be cpp. --- tools/platforms/WindowsPlatform.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 9fc29c3340..1b2ab488be 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -810,7 +810,7 @@ class WindowsPlatform extends PlatformTarget if (!targetFlags.exists("32") && !targetFlags.exists("x86_32") && System.hostArchitecture == X64 - && (command != "rebuild" || targetType == "cpp" || targetType == "winrt")) + && (command != "rebuild" || targetType == "cpp" || targetType == "neko" || targetType == "winrt")) { if (targetType == "winrt") { From d15731fa12636c9a3c43f082db6330de24dfdbca Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 18 Dec 2024 22:19:45 +0000 Subject: [PATCH 09/11] Fix static build with mingw `wbemuuid.lib` must be linked explicitly, since #pragma comment(lib, ...) only works with msvc. `comsuppw.lib` does not exist in mingw. `no_shared_libs` must be set for mingw to ensure the standard library and other libraries are linked statically. `.lib` must be replaced with `${LIBEXT}` so that it resolves to `.a` on mingw. --- templates/cpp/static/BuildMain.xml | 5 ++++- tools/platforms/WindowsPlatform.hx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/cpp/static/BuildMain.xml b/templates/cpp/static/BuildMain.xml index 6813ce32dc..dd135172ce 100644 --- a/templates/cpp/static/BuildMain.xml +++ b/templates/cpp/static/BuildMain.xml @@ -2,6 +2,8 @@ + + @@ -36,7 +38,8 @@ - + + diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 1b2ab488be..7a47a9f9a4 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -986,12 +986,12 @@ class WindowsPlatform extends PlatformTarget var msvc19 = true; - if ((!hasVSCommunity && vs140 == null) || (hxcppMSVC != null && hxcppMSVC != vs140)) + if (project.defines.exists("mingw") || (!hasVSCommunity && vs140 == null) || (hxcppMSVC != null && hxcppMSVC != vs140)) { msvc19 = false; } - var suffix = (msvc19 ? "-19.lib" : ".lib"); + var suffix = (msvc19 ? "-19" : "") + "${LIBEXT}"; for (i in 0...project.ndlls.length) { From 468849f5f48acc4c5f88d767cd8e69882d78719e Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 7 Sep 2025 12:06:23 +0100 Subject: [PATCH 10/11] Link with bcrypt.lib on windows for curl MSVC links this automatically due to a #pragma in curl's source code, but other compilers require it to be added explicitly. --- project/Build.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/Build.xml b/project/Build.xml index 315a262fa8..2fad179401 100755 --- a/project/Build.xml +++ b/project/Build.xml @@ -430,6 +430,8 @@ + + From 3eee8f118d9e41279ca68238e3914a56b571bbc1 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 20 Dec 2025 01:53:34 +0000 Subject: [PATCH 11/11] [ci] Add mingw 64-bit ndll build --- .github/workflows/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99667601ae..6b3512a76d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -274,6 +274,19 @@ jobs: lime create SimpleAudio -verbose -nocolor lime build SimpleAudio windows -release -verbose -nocolor + - name: Rebuild Lime (Windows, Mingw) + run: | + rm ndll/Windows64/* + lime rebuild windows -Dmingw -D MINGW_ROOT=C:\mingw64 -64 -clean -release -nocolor -verbose -nocffi + + - uses: actions/upload-artifact@v4 + with: + name: Windows64-MinGW-NDLL + path: | + ndll/Windows64/ + !**/.gitignore + if-no-files-found: error + android: runs-on: ubuntu-22.04 strategy: