diff -Nur --exclude '*.obj' --exclude '*.exp' --exclude '*.lib' --exclude '*.idb' '--exclude=osgeo4w' fcgi2-2.4.2/include/fcgi_config.h ../include/fcgi_config.h
--- fcgi2-2.4.2/include/fcgi_config.h	1970-01-01 01:00:00.000000000 +0100
+++ ../include/fcgi_config.h	2020-11-17 18:08:42.348163900 +0100
@@ -0,0 +1,39 @@
+/* 
+ *  Copied to fcgi_config.h when building on WinNT without cygwin,
+ *  i.e. configure is not run.  See fcgi_config.h.in for details.
+ */
+
+#define HAVE_FPOS 1
+#define HAVE_LIMITS_H 1
+#define HAVE_STREAMBUF_CHAR_TYPE 1
+#define HAVE_STRERROR 1
+#undef HAVE_ARPA_INET_H
+#undef HAVE_DLFCN_H
+#undef HAVE_FILENO_PROTO
+#undef HAVE_INTTYPES_H
+#undef HAVE_IOSTREAM_WITHASSIGN_STREAMBUF
+#undef HAVE_LIBNSL
+#undef HAVE_LIBSOCKET
+#undef HAVE_MEMORY_H
+#undef HAVE_NETDB_H
+#undef HAVE_NETINET_IN_H
+#undef HAVE_PTHREAD
+#undef HAVE_SOCKADDR_UN_SUN_LEN
+#undef HAVE_SOCKLEN
+#undef HAVE_STDINT_H
+#undef HAVE_STDLIB_H
+#undef HAVE_STRING_H
+#undef HAVE_STRINGS_H
+#undef HAVE_SYS_PARAM_H
+#undef HAVE_SYS_SOCKET_H
+#undef HAVE_SYS_STAT_H
+#undef HAVE_SYS_TIME_H
+#undef HAVE_SYS_TYPES_H
+#undef HAVE_UNISTD_H
+#undef HAVE_VA_ARG_LONG_DOUBLE_BUG
+#undef PTHREAD_CREATE_JOINABLE
+#undef STDC_HEADERS
+#undef USE_LOCKING
+#undef const
+#undef inline
+#undef ssize_t
diff -Nur --exclude '*.obj' --exclude '*.exp' --exclude '*.lib' --exclude '*.idb' '--exclude=osgeo4w' fcgi2-2.4.2/libfcgi/fcgi_stdio.c ../libfcgi/fcgi_stdio.c
--- fcgi2-2.4.2/libfcgi/fcgi_stdio.c	2019-02-19 12:19:19.000000000 +0100
+++ ../libfcgi/fcgi_stdio.c	2020-11-17 18:08:42.350148400 +0100
@@ -107,6 +107,11 @@
 static int acceptCalled = FALSE;
 static int isCGI = FALSE;
 
+#ifdef WIN32
+#include <fcntl.h>
+#include <io.h>
+#endif
+
 int FCGI_Accept(void)
 {
     if(!acceptCalled) {
@@ -131,6 +136,11 @@
         FCGI_stdout->fcgx_stream = NULL;
         FCGI_stderr->stdio_stream = stderr;
         FCGI_stderr->fcgx_stream = NULL;
+
+#ifdef _WIN32
+	_setmode( _fileno(stdout), _O_BINARY);
+	_setmode( _fileno(stdin), _O_BINARY);
+#endif
     } else {
         FCGX_Stream *in, *out, *error;
         FCGX_ParamArray envp;
