diff -ur a/SCons/Config/gnu b/SCons/Config/gnu
--- a/SCons/Config/gnu	2022-09-20 00:40:30.000000000 +0800
+++ b/SCons/Config/gnu	2024-05-24 20:20:50.395307400 +0800
@@ -19,7 +19,8 @@
 ### cross compiling
 
 def cross_env(env):
-	if env['PLATFORM'] != 'win32':
+	import sys
+	if not 'MSC' in sys.version:
 		env.Tool('crossmingw', toolpath = [Dir('../Tools').rdir()])
 
 ### flags
@@ -41,7 +42,7 @@
 defenv['ENTRY_FLAG'] = entry
 defenv['MAP_FLAG'] = '-Wl,-Map,${TARGET.base}.map'
 defenv['EXCEPTION_FLAG'] = ''
-defenv['NODEFLIBS_FLAG'] = '-nostdlib -Wl,--exclude-libs,msvcrt.a'
+defenv['NODEFLIBS_FLAG'] = '-nostdlib'
 defenv['C_FLAG'] = '-xc'
 defenv['CPP_FLAG'] = '-xc++'
 defenv['ALIGN_FLAG'] = '-Wl,--file-alignment,512'
@@ -50,11 +51,14 @@
 defenv['SUBSYS_WIN'] = '-Wl,--subsystem,windows'
 defenv['MSVCRT_FLAG'] = ''
 defenv['STDCALL'] = '"__attribute__((__stdcall__))"'
+defenv['SHLIBPREFIX'] = ''
+defenv['PLATFORM'] = 'win32'
 
 # Don't allow mingw to link with LIBGCC*.DLL and LIBSTDC++-*.DLL
 def configure_static_libs(env):
 	env.Append(LINKFLAGS = ['-static-libgcc'])
 	env.Append(LINKFLAGS = ['-static-libstdc++']) # MinGW GCC 4.5.2 warns about unrecognized option but it also actually needs it!
+	env.Append(LINKFLAGS = ['-static'])
 
 if defenv['PLATFORM'] == 'win32':
 	configure_static_libs(defenv)
@@ -320,7 +324,8 @@
 #
 
 conf = FlagsConfigure(makensis_env)
-conf.CheckLinkFlag('-pthread', codeprepend = code_failonmswin)
+if defenv['PLATFORM'] != 'win32':
+	conf.CheckLinkFlag('-pthread', codeprepend = code_failonmswin)
 conf.Finish()
 
 #
diff -ur a/Source/util.cpp b/Source/util.cpp
--- a/Source/util.cpp	2023-12-21 14:32:34.000000000 +0800
+++ b/Source/util.cpp	2024-05-24 20:13:54.711346900 +0800
@@ -1203,7 +1203,10 @@
 {
   STARTUPINFO si = { sizeof(STARTUPINFO), };
   PROCESS_INFORMATION pi;
-  if (!CreateProcess(NULL, const_cast<LPSTR>(cmd), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
+  LPSTR modifiable_cmd = strdup(cmd);
+  BOOL result = CreateProcess(NULL, modifiable_cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+  free(modifiable_cmd);
+  if (!result)
     return GetLastError();
   WaitForSingleObject(pi.hProcess, INFINITE);
   GetExitCodeProcess(pi.hProcess, &si.cb);
