From 5ccd2486221930b3a918362b27cea3120d194b3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Wed, 18 Aug 2010 18:55:45 +0200
Subject: [PATCH] Build system: for Windows, add "-static-libstdc++" flag

---
 configure.ac     | 4 +++-
 m4/ax_mexopts.m4 | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6de5cee6c9..d7b40160de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,9 @@ AC_PROG_CXX
 AC_CANONICAL_HOST
 case ${host_os} in
   *mingw32*)
-    LDFLAGS="$LDFLAGS -static-libgcc" # On mingw32, we don't want dynamic libgcc
+    # On mingw32, we don't want dynamic libgcc
+    # Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions)
+    LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
     ;;
   *cygwin*)
     AC_MSG_WARN([You are compiling for the Cygwin target. This means that the preprocessor will])
diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4
index 21b1af55d0..e52c36b5bc 100644
--- a/m4/ax_mexopts.m4
+++ b/m4/ax_mexopts.m4
@@ -62,7 +62,8 @@ case ${MATLAB_ARCH} in
         ;;
     esac
     MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
-    MATLAB_LDFLAGS="-static-libgcc -shared \$(top_srcdir)/mex.def"
+    # Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions)
+    MATLAB_LDFLAGS="-static-libgcc -static-libstdc++ -shared \$(top_srcdir)/mex.def"
     MATLAB_LIBS="$LIBLOC/libmex.lib $LIBLOC/libmx.lib $LIBLOC/libmwlapack.lib"
     # Starting from MATLAB 7.5, BLAS and LAPACK are in distinct libraries
     AX_COMPARE_VERSION([$MATLAB_VERSION], [ge], [7.5], [MATLAB_LIBS="${MATLAB_LIBS} $LIBLOC/libmwblas.lib"])
-- 
GitLab