diff -rup libssh2-0.15-20070328/configure.in libssh2-0.15-new/configure.in
--- libssh2-0.15-20070328/configure.in	2007-03-28 04:02:06.000000000 +0200
+++ libssh2-0.15-new/configure.in	2007-03-29 04:28:30.740011200 +0200
@@ -22,6 +22,18 @@ case "$host" in
     ;;
 esac
 
+AC_MSG_CHECKING([if we need -no-undefined])
+case $host in
+  *-*-cygwin | *-*-mingw* | *-*-pw32*)
+    need_no_undefined=yes
+    ;;
+  *)
+    need_no_undefined=no
+    ;;
+esac
+AC_MSG_RESULT($need_no_undefined)
+AM_CONDITIONAL(NO_UNDEFINED, test x$need_no_undefined = xyes)
+
 # Some systems (Solaris?) have socket() in -lsocket.
 AC_SEARCH_LIBS(socket, socket)
 
diff -rup libssh2-0.15-20070328/include/libssh2.h libssh2-0.15-new/include/libssh2.h
--- libssh2-0.15-20070328/include/libssh2.h	2007-02-08 04:02:09.000000000 +0100
+++ libssh2-0.15-new/include/libssh2.h	2007-03-29 04:24:04.877720000 +0200
@@ -63,7 +63,7 @@ extern "C" {
 # include <sys/uio.h>
 #endif
 
-#if defined(LIBSSH2_WIN32) && _MSC_VER < 1300
+#if defined(LIBSSH2_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1300)
 typedef unsigned __int64 libssh2_uint64_t;
 typedef __int64 libssh2_int64_t;
 #else
diff -rup libssh2-0.15-20070328/src/Makefile.am libssh2-0.15-new/src/Makefile.am
--- libssh2-0.15-20070328/src/Makefile.am	2007-02-03 04:02:06.000000000 +0100
+++ libssh2-0.15-new/src/Makefile.am	2007-03-29 04:37:05.790617600 +0200
@@ -50,4 +50,9 @@ VERSION=-version-info 1:0:0
 # set age to 0. (c:r:a=0)
 #
 
-libssh2_la_LDFLAGS = $(VERSION)
+if NO_UNDEFINED
+# The -no-undefined flag is CRUCIAL for this to build fine on Cygwin.
+UNDEF = -no-undefined
+endif
+
+libssh2_la_LDFLAGS = $(UNDEF) $(VERSION)
