This is yet another DLL problem. Either add
-static
to the compiler flags (or rather linker flags), or move C:\msys64\ucrt64\bin
(or whatever subdirectory you added to the PATH) to be the first directory in the system-wide PATH (rather than the user-specific PATH). Or copy the right DLLs to be next to the .exe (ntldd -R my_program.exe
will tell you the list, ignore anything not shipped with your compiler).