On Sun, 23 Nov 2025, Kirill Makurin wrote:

If you look at gcc spec, you will see -lkernel32 following mingw-w64's -l flags. The issue is that this will cause mingw-w64's static code directly reference symbols from kernel32.dll, and not api sets linked with -lwindowsapp. Perfectly, we would want to replace this -lkernel32 with -lwindowsappcompat -lwindowsapp. However, there seems to be no simple way to achieve this.

One way this can be achieved is by getting the specs with `gcc -dumpspecs`, modifying them (with sed, for example) and passing modified specs to gcc with -specs=. I see no simple way how this can be done with build systems like meson or cmake. This also would not work for clang.

Yes, this is exactly how VLC did it, when building with GCC - they run -dumpspecs, then edit the spec file and pass -specs= when compiling: https://code.videolan.org/videolan/vlc/-/blob/3.0.21/extras/package/win32/build.sh?ref_type=tags#L227-239

In Clang, we check if the user specified -lwindowsapp - in that case, it omits the built-in -lkernel32 and similar: https://github.com/llvm/llvm-project/blob/llvmorg-21.1.6/clang/lib/Driver/ToolChains/MinGW.cpp#L284-L290 and https://github.com/llvm/llvm-project/blob/llvmorg-21.1.6/clang/lib/Driver/ToolChains/MinGW.cpp#L350-L362

(Similarly, in Clang, if you pass -lmsvcr*, -lucrt* or -lcrtdll, it omits the default -lmsvcrt.)

// Martin



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to