diff -ur a/Contrib/AdvSplash/SConscript b/Contrib/AdvSplash/SConscript
--- a/Contrib/AdvSplash/SConscript	2005-05-04 01:31:56.000000000 +0800
+++ b/Contrib/AdvSplash/SConscript	2024-05-24 23:25:58.341875700 +0800
@@ -2,6 +2,8 @@
 
 files = Split("""
 	advsplash.c
+	memcpy.c
+	memset.c
 """)
 
 libs = Split("""
diff -ur a/Contrib/VPatch/Source/GenPat/POSIXUtil.cpp b/Contrib/VPatch/Source/GenPat/POSIXUtil.cpp
--- a/Contrib/VPatch/Source/GenPat/POSIXUtil.cpp	2012-02-29 06:40:43.000000000 +0800
+++ b/Contrib/VPatch/Source/GenPat/POSIXUtil.cpp	2024-05-24 23:25:58.357502800 +0800
@@ -41,6 +41,7 @@
 #endif
 
 #ifdef __WIN32__     /* The Windows way of getting a temp file needs windows.h*/
+  #define WIN32_LEAN_AND_MEAN
   #include <windows.h>
 #endif
 
diff -ur a/Contrib/VPatch/Source/GenPat/SConscript b/Contrib/VPatch/Source/GenPat/SConscript
--- a/Contrib/VPatch/Source/GenPat/SConscript	2012-11-11 11:12:50.000000000 +0800
+++ b/Contrib/VPatch/Source/GenPat/SConscript	2024-05-24 23:25:58.420006300 +0800
@@ -18,4 +18,4 @@
 
 Import('BuildUtil')
 
-BuildUtil(target, files, libs, flags = ['$EXCEPTION_FLAG'], cross_platform = True, cli = True)
+BuildUtil(target, files, libs, flags = ['$EXCEPTION_FLAG', '-DNOCRYPT', '-DNOGDI', '-DNOSHLWAPI'], cross_platform = True, cli = True)
diff -ur a/Contrib/nsDialogs/SConscript b/Contrib/nsDialogs/SConscript
--- a/Contrib/nsDialogs/SConscript	2014-02-10 02:36:53.000000000 +0800
+++ b/Contrib/nsDialogs/SConscript	2024-05-24 23:25:58.466911800 +0800
@@ -6,6 +6,8 @@
 	nsDialogs.c
 	nsDialogs.def
 	rtl.c
+	memcpy.c
+	memset.c
 """)
 
 resources = Split("""
diff -ur a/SConstruct b/SConstruct
--- a/SConstruct	2022-09-03 04:02:06.000000000 +0800
+++ b/SConstruct	2024-05-24 23:25:58.482531300 +0800
@@ -795,6 +795,7 @@
 			env.Append(LINKFLAGS = env['SUBSYS_CON'])
 		else:
 			env.Append(LINKFLAGS = env['SUBSYS_WIN'])
+		env.Append(LINKFLAGS = ['-static'])
 
 	AddEnvStandardFlags(env, defines, flags, libs, entry, nodeflib)
 
diff -ur a/Source/Platform.h b/Source/Platform.h
--- a/Source/Platform.h	2023-01-26 21:51:19.000000000 +0800
+++ b/Source/Platform.h	2024-05-24 23:25:58.545031500 +0800
@@ -39,7 +39,6 @@
 #include <commctrl.h>
 #include <shellapi.h>
 #include <shlwapi.h>
-#include <shlobj.h>
 #else
 #  include <stdint.h>
 #  ifndef EXEHEAD
@@ -347,8 +346,11 @@
 
 // shell folders
 
-#ifdef _WIN32
+#if defined(_WIN32) && defined(EXEHEAD)
 #  include <shlobj.h>
+#ifndef SHGFP_TYPE_CURRENT
+  #define SHGFP_TYPE_CURRENT 0
+#endif
 #endif
 
 #ifndef CSIDL_FLAG_CREATE
@@ -488,10 +490,6 @@
 #  define CSIDL_CDBURN_AREA 0x3B
 #endif
 
-#ifndef SHGFP_TYPE_CURRENT
-  #define SHGFP_TYPE_CURRENT 0
-#endif
-
 // other shell stuff
 
 #ifndef SHACF_FILESYSTEM
diff -ur a/Source/SConscript b/Source/SConscript
--- a/Source/SConscript	2021-08-19 07:48:20.000000000 +0800
+++ b/Source/SConscript	2024-05-24 23:25:58.560653700 +0800
@@ -53,8 +53,6 @@
 libs = Split("""
 	gdi32
 	user32
-	pthread
-	iconv
 	shlwapi
 	oleaut32
 	version
diff -ur a/Source/Tests/SConscript b/Source/Tests/SConscript
--- a/Source/Tests/SConscript	2022-01-08 07:45:06.000000000 +0800
+++ b/Source/Tests/SConscript	2024-05-24 23:25:58.607530400 +0800
@@ -69,10 +69,7 @@
 """)
 
 extralibs = Split("""
-	dl
 	gdi32
-	iconv
-	pthread
 	user32
 	oleaut32
 """)
diff -ur a/Source/build.cpp b/Source/build.cpp
--- a/Source/build.cpp	2023-07-28 01:18:23.532000000 +0800
+++ b/Source/build.cpp	2024-05-24 23:25:58.701283400 +0800
@@ -3742,7 +3742,7 @@
     }
   };
   size_t io[] = { false, (size_t) path, pathcap }, cb;
-  TinyGrowBuf inputbuf((IGrowBuf::size_type) (cb = FIELD_OFFSET(PROMPT_FILEPATH_DATA, Path[pathcap])));
+  TinyGrowBuf inputbuf((IGrowBuf::size_type) (cb = FIELD_OFFSET(PROMPT_FILEPATH_DATA, Path[sizeof(UINT)])));
   PROMPT_FILEPATH_DATA *p = (PROMPT_FILEPATH_DATA*) inputbuf.get();
   p->Platform = (sizeof(void*) * 8) | sizeof(TCHAR), p->Reserved = 0;
   _tcscpy(p->Path, path);
diff -ur a/Source/exehead/SConscript b/Source/exehead/SConscript
--- a/Source/exehead/SConscript	2020-06-30 07:08:12.000000000 +0800
+++ b/Source/exehead/SConscript	2024-05-24 23:25:58.685662800 +0800
@@ -7,6 +7,8 @@
 	plugin.c
 	Ui.c
 	util.c
+	memcpy.c
+	memset.c
 	#Source/crc32.c
 """)
 
@@ -50,6 +52,7 @@
 
 ### Defines
 
+env.Append(CXXFLAGS = ['-std=c++11'])
 env.Append(CPPDEFINES = ['EXEHEAD'])
 env.Append(CPPDEFINES = ['WIN32_LEAN_AND_MEAN'])
 env.Append(CPPDEFINES = ['_WIN32_IE=0x0500'])
