I installed msys2 and I'm using the UCRT64 environment that comes with it. I installed the mingw-w64-ucrt-x86_64-toolchain group of packages, which I am using to compile C++.
I have a file which compiles as a static library libtestwin64.a and contains this:
#include <windows.h> // contains <winuser.h> <wingdi.h>
void funcA() {
    HDC dc = GetDC(NULL); // references to <winuser.h> cause no error. 
    HCOLORSPACE hcs = GetColorSpace(dc); // references to <wingdi.h> cause error. 
}
When I try to link with libtestwin64.a and compile an executable g++ -I../mirr/inc   obj/Win64/three.o obj/Win64/four.o -o ../bin/test64.exe -luser32 -lgdi32 -L../mirr/lib  -ltestwin64, it causes these undefined reference errors for anything from wingdi.h:
D:/software/msys/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
../mirr/lib/libtestwin64.a(one.o):one.cpp:(.text+0xfd): undefined reference to `__imp_GetColorSpace'
ld.exe reports no error about finding the files libgdi32.a etc. Adding options like -lgdi32 to the linker doesn't change the result. Other system libraries like libuser32.a cause no error.
What can I do to use functions from Windows GDI through msys2?
