diff --git a/configure b/configure
index 04b7d0d0207a552dacdd37ffa11ce1b554ea840d..44b62a44861a668fd6bddd485d01c79fdb285460 100755
--- a/configure
+++ b/configure
@@ -3177,6 +3177,10 @@ if test ! "x$enable_pgsql" = "xno"; then
 
     if test "x$pgsqlincdir" = "x" || test "x$pgsqllib" = "x"; then
         enable_pgsql="no"
+    else
+        if test "x$arch" = xwin32gcc; then
+            pgsqllib="$pgsqllib -lssl -lldap -lcrypto -lintl"
+        fi
     fi
 fi
 check_explicit "$enable_pgsql" "$enable_pgsql_explicit" \