diff --git a/configure.ac b/configure.ac
index 6de5cee6c9d615ba378d5d78ccc695299d5baa53..d7b40160de2d1f37cd1eaef1c46e2047c195b0d8 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 21b1af55d057c665f92000eb5f636d4b89561a0d..e52c36b5bc4aa19bcad9f85f60651361ac9a525c 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"])