diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h
index 9fdea05..08b7dbe 100644
--- a/binding-mri/binding-util.h
+++ b/binding-mri/binding-util.h
@@ -23,6 +23,7 @@
 #define BINDING_UTIL_H
 
 #include <ruby.h>
+#undef inline //ruby's config.h has #define inline __inline, which cause error in xkeycheck.h
 
 #include "exception.h"
 
diff --git a/binding-mri/table-binding.cpp b/binding-mri/table-binding.cpp
index 12643f5..5f15fa9 100644
--- a/binding-mri/table-binding.cpp
+++ b/binding-mri/table-binding.cpp
@@ -19,6 +19,10 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef _MSC_VER
+#define NOMINMAX
+#endif
+
 #include <algorithm>
 #include "table.h"
 #include "binding-util.h"
diff --git a/src/alstream.cpp b/src/alstream.cpp
index 1a8d73c..e066b0b 100644
--- a/src/alstream.cpp
+++ b/src/alstream.cpp
@@ -19,6 +19,7 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "crossplatform.h"
 #include "alstream.h"
 
 #include "sharedstate.h"
diff --git a/src/config.cpp b/src/config.cpp
index 998d6ea..eda0e7f 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -380,7 +380,11 @@ void Config::readGameINI()
 			size_t inLen = game.title.size();
 			size_t outLen = inLen * 4;
 			std::string buf(outLen, '\0');
+#ifdef _MSC_VER
+			const char *inPtr = game.title.c_str();
+#else
 			char *inPtr = const_cast<char*>(game.title.c_str());
+#endif
 			char *outPtr = const_cast<char*>(buf.c_str());
 
 			errno = 0;
diff --git a/src/crossplatform.h b/src/crossplatform.h
new file mode 100644
index 0000000..26f4993
--- /dev/null
+++ b/src/crossplatform.h
@@ -0,0 +1,17 @@
+#ifndef MKXP_CROSSPLATFORM_H
+#define MKXP_CROSSPLATFORM_H
+
+#ifdef _MSC_VER
+//#define _CRT_SECURE_NO_DEPRECATE //should be defined in binding-mri's preprocessor for vsnprintf, fopen
+
+#include <direct.h>
+
+#ifndef snprintf
+#define snprintf _snprintf
+#endif
+#ifndef chdir
+#define chdir _chdir
+#endif
+#endif
+
+#endif //MKXP_CROSSPLATFORM_H
diff --git a/src/eventthread.cpp b/src/eventthread.cpp
index 21ef917..b5415e5 100644
--- a/src/eventthread.cpp
+++ b/src/eventthread.cpp
@@ -19,6 +19,7 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "crossplatform.h"
 #include "eventthread.h"
 
 #include <SDL_events.h>
diff --git a/src/exception.h b/src/exception.h
index 6f95b60..f7b3354 100644
--- a/src/exception.h
+++ b/src/exception.h
@@ -22,6 +22,8 @@
 #ifndef EXCEPTION_H
 #define EXCEPTION_H
 
+#include "crossplatform.h"
+
 #include <string>
 #include <stdio.h>
 #include <stdarg.h>
diff --git a/src/filesystem.cpp b/src/filesystem.cpp
index 576b27d..d550623 100644
--- a/src/filesystem.cpp
+++ b/src/filesystem.cpp
@@ -19,6 +19,7 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "crossplatform.h"
 #include "filesystem.h"
 
 #include "rgssad.h"
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 109a2a8..5c2d70c 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -43,7 +43,9 @@
 #include <SDL_image.h>
 
 #include <time.h>
+#ifndef _MSC_VER
 #include <sys/time.h>
+#endif
 #include <errno.h>
 #include <algorithm>
 
diff --git a/src/keybindings.cpp b/src/keybindings.cpp
index caa86b4..8c9b801 100644
--- a/src/keybindings.cpp
+++ b/src/keybindings.cpp
@@ -19,6 +19,7 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "crossplatform.h"
 #include "keybindings.h"
 
 #include "config.h"
diff --git a/src/main.cpp b/src/main.cpp
index d70a26f..4922800 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,11 +26,14 @@
 #include <SDL_ttf.h>
 #include <SDL_sound.h>
 
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <string.h>
 #include <assert.h>
 #include <string>
 
+#include "crossplatform.h"
 #include "sharedstate.h"
 #include "eventthread.h"
 #include "gl-debug.h"
@@ -377,4 +380,4 @@ int main(int argc, char *argv[])
 	SDL_Quit();
 
 	return 0;
-}
+}
\ No newline at end of file
diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp
index 42e2c47..1009cde 100644
--- a/src/settingsmenu.cpp
+++ b/src/settingsmenu.cpp
@@ -19,6 +19,7 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "crossplatform.h"
 #include "settingsmenu.h"
 
 #include <SDL_video.h>
diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp
index 7bf6343..5bb844d 100644
--- a/src/sharedstate.cpp
+++ b/src/sharedstate.cpp
@@ -38,7 +38,9 @@
 #include "exception.h"
 #include "sharedmidistate.h"
 
+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
 #include <stdio.h>
 #include <string>
 
diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp
index 0fd5dcf..c4281fd 100644
--- a/src/soundemitter.cpp
+++ b/src/soundemitter.cpp
@@ -19,6 +19,7 @@
 ** along with mkxp.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "crossplatform.h"
 #include "soundemitter.h"
 
 #include "sharedstate.h"
diff --git a/src/util.h b/src/util.h
index 661cd9d..63bf4a0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -22,6 +22,8 @@
 #ifndef UTIL_H
 #define UTIL_H
 
+#include "crossplatform.h"
+
 #include <stdio.h>
 #include <string>
 #include <algorithm>