diff --git a/configure.ac b/configure.ac
index a65361a..2e86030 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,7 @@ define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])
 dnl Check for programs
 AC_PROG_CC
 AC_PROG_INSTALL
-AC_PROG_LIBTOOL
+LT_INIT([win32-dll])
 
 dnl Check for math library
 AC_CHECK_LIB([m], [exp])
@@ -101,6 +101,42 @@ else
    AC_MSG_RESULT([no])
 fi
 
+dnl Configs for Windows DLLs.
+dnl libtool requires "-no-undefined" for win32 dll
+case $host_os in
+  cygwin* | mingw*)
+   if test "$enable_shared" = yes; then
+     NOUNDEFINED=" -no-undefined"
+     if test "$with_gmp" = yes; then
+       AC_MSG_CHECKING(for DLL/static GMP)
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include "gmp.h"
+#if !__GMP_LIBGMP_DLL
+# error "Dead man"
+error
+#endif
+       ]], [[]])],[AC_MSG_RESULT(DLL)],[
+    AC_MSG_RESULT(static)
+    AC_MSG_ERROR([gmp.h isn't a DLL: use --enable-static --disable-shared]) ])
+     fi
+   fi
+   if test "$enable_static" = yes; then
+     if test "$with_gmp" = yes; then
+       AC_MSG_CHECKING(for DLL/static GMP)
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include "gmp.h"
+#if __GMP_LIBGMP_DLL
+# error "Dead man"
+error
+#endif
+       ]], [[]])],[AC_MSG_RESULT(static)],[
+    AC_MSG_RESULT(DLL)
+    AC_MSG_ERROR([gmp.h is a DLL: use --disable-static --enable-shared]) ])
+    fi
+  fi
+  ;;
+esac
+
 case $host_os in
    darwin* | macosx*)
       LIBIODBC="libiodbc.dylib"
