From d663b5bc88a66804db8c865fdc97deeb33b40029 Mon Sep 17 00:00:00 2001 From: Feiyun Wang Date: Sun, 2 Apr 2023 22:46:40 +0800 Subject: [PATCH 1/2] Fix #1064: Can't open dynamic library, and LINKFLAGS typo for "-static" --- tools/windows.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/windows.py b/tools/windows.py index e64695ae1..c5490609c 100644 --- a/tools/windows.py +++ b/tools/windows.py @@ -45,13 +45,27 @@ def generate(env): env["SHLIBPREFIX"] = "" # Want dll suffix env["SHLIBSUFFIX"] = ".dll" + + # These options are for a release build even using target=template_debug + env.Append(CCFLAGS=["-O3", "-Wwrite-strings"]) + env.Append( + LINKFLAGS=[ + "-static", + "-Wl,--no-undefined", + "-static-libgcc", + "-static-libstdc++", + ] + ) + # Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other). my_spawn.configure(env) else: env["use_mingw"] = True # Cross-compilation using MinGW - prefix = "i686" if env["arch"] == "x86_32" else env["arch"] + prefix = "i686" + if env["arch"] == "x86_64": + prefix = "x86_64" env["CXX"] = prefix + "-w64-mingw32-g++" env["CC"] = prefix + "-w64-mingw32-gcc" env["AR"] = prefix + "-w64-mingw32-ar" @@ -60,11 +74,11 @@ def generate(env): # Want dll suffix env["SHLIBSUFFIX"] = ".dll" - # These options are for a release build even using target=debug + # These options are for a release build even using target=template_debug env.Append(CCFLAGS=["-O3", "-Wwrite-strings"]) env.Append( LINKFLAGS=[ - "--static", + "-static", "-Wl,--no-undefined", "-static-libgcc", "-static-libstdc++", From f5b0478baf32e4c53d357f56483b4797e2b456f3 Mon Sep 17 00:00:00 2001 From: Feiyun Wang Date: Sat, 8 Apr 2023 20:14:07 +0800 Subject: [PATCH 2/2] Remove "-O3" for CCFLAGS in tools/windows.py ("-O3" overridden and handled by Scons options "debug_symbols" and "optimize" in tools/targets.py) --- tools/windows.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/windows.py b/tools/windows.py index c5490609c..b8718b969 100644 --- a/tools/windows.py +++ b/tools/windows.py @@ -46,8 +46,7 @@ def generate(env): # Want dll suffix env["SHLIBSUFFIX"] = ".dll" - # These options are for a release build even using target=template_debug - env.Append(CCFLAGS=["-O3", "-Wwrite-strings"]) + env.Append(CCFLAGS=["-Wwrite-strings"]) env.Append( LINKFLAGS=[ "-static", @@ -74,8 +73,7 @@ def generate(env): # Want dll suffix env["SHLIBSUFFIX"] = ".dll" - # These options are for a release build even using target=template_debug - env.Append(CCFLAGS=["-O3", "-Wwrite-strings"]) + env.Append(CCFLAGS=["-Wwrite-strings"]) env.Append( LINKFLAGS=[ "-static",