diff --git a/src/common.c b/src/common.c
index afe1bc0..9219a8f 100644
--- a/src/common.c
+++ b/src/common.c
@@ -29,7 +29,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#ifndef _MSC_VER
 #include <libgen.h>
+#endif
 #include <time.h>
 
 #include "common.h"
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index efa13c3..c17a2ba 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -38,12 +38,12 @@
 #include <string.h>
 #ifndef _MSC_VER
 #include <unistd.h>
+#include <libgen.h>
 #endif
 #include <ctype.h>
 #include <getopt.h>
 #include <plist/plist.h>
 #include <zlib.h>
-#include <libgen.h>
 
 #include <curl/curl.h>
 
