diff -aur ImageMagick-7.0.7-23/MagickCore/distribute-cache.c.orig ImageMagick-7.0.7-23/MagickCore/distribute-cache.c
--- ImageMagick-7.0.7-23/MagickCore/distribute-cache.c.orig	2018-02-24 21:32:34.666271100 -0500
+++ ImageMagick-7.0.7-23/MagickCore/distribute-cache.c	2018-02-24 21:42:13.327124000 -0500
@@ -51,6 +51,10 @@
 /*
   Include declarations.
 */
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
 #include "MagickCore/studio.h"
 #include "MagickCore/cache.h"
 #include "MagickCore/cache-private.h"
diff -aur ImageMagick-7.0.7-23/MagickCore/nt-base.h.orig ImageMagick-7.0.7-23/MagickCore/nt-base.h
--- ImageMagick-7.0.7-23/MagickCore/nt-base.h.orig	2018-02-18 19:43:40.000000000 -0500
+++ ImageMagick-7.0.7-23/MagickCore/nt-base.h	2018-02-24 21:28:10.703040900 -0500
@@ -30,7 +30,11 @@ extern "C" {
 
 #define WIN32_LEAN_AND_MEAN
 #define VC_EXTRALEAN
+#ifndef __MINGW32__
 #define _CRT_SECURE_NO_DEPRECATE  1
+#endif
+#include <winsock2.h>
+#include <ws2tcpip.h>
 #include <windows.h>
 #include <wchar.h>
 #include <winuser.h>
@@ -95,7 +97,7 @@ extern "C" {
 #if !defined(closedir)
 #  define closedir(directory)  NTCloseDirectory(directory)
 #endif
-#define MAGICKCORE_HAVE_ERF
+//#define MAGICKCORE_HAVE_ERF
 #if defined(_VISUALC_) && (_MSC_VER < 1700)
 #  define erf(x)  NTErf(x)
 #endif
diff -aur ImageMagick-7.0.9-2/MagickCore/nt-base.c.orig ImageMagick-7.0.9-2/MagickCore/nt-base.c > patch
--- ImageMagick-7.0.9-2/MagickCore/nt-base.c.orig	2017-01-02 23:52:31.225966200 -0500
+++ ImageMagick-7.0.9-2/MagickCore/nt-base.c	2017-01-03 00:06:00.213705700 -0500
@@ -1794,12 +1794,16 @@
   wchar_t
     file_specification[MagickPathExtent];
 
+  wchar_t WCDirectorySeparator[strlen(DirectorySeparator)+1];
+  MultiByteToWideChar(CP_UTF8,0,DirectorySeparator,-1,WCDirectorySeparator,
+                     strlen(DirectorySeparator)+1);
+
   assert(path != (const char *) NULL);
   length=MultiByteToWideChar(CP_UTF8,0,path,-1,file_specification,
     MagickPathExtent);
   if (length == 0)
     return((DIR *) NULL);
-  if (wcsncat(file_specification,(const wchar_t*) DirectorySeparator,
+  if(wcsncat(file_specification, WCDirectorySeparator,
         MagickPathExtent-wcslen(file_specification)-1) == (wchar_t *) NULL)
     return((DIR *) NULL);
   entry=(DIR *) AcquireCriticalMemory(sizeof(DIR));
diff -aur ImageMagick-7.0.9-2/MagickCore/studio.h.orig ImageMagick-7.0.9-2/MagickCore/studio.h > patch
--- ImageMagick-7.0.9-2/MagickCore/studio.h.orig	2017-01-02 23:52:31.225966200 -0500
+++ ImageMagick-7.0.9-2/MagickCore/studio.h	2017-01-03 00:06:00.213705700 -0500
@@ -128,7 +128,9 @@
 #include <ws2tcpip.h>
 #endif
 #include <windows.h>
+#ifdef _MSC_VER
 #pragma comment (lib, "ws2_32.lib")
+#endif
 #endif
 #if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H)
 # include <sys/syslimits.h>
