diff --git a/VS2012/civetweb_lua/civetweb_lua.vcxproj b/VS2012/civetweb_lua/civetweb_lua.vcxproj
index 6a0a6a95..88db00d3 100644
--- a/VS2012/civetweb_lua/civetweb_lua.vcxproj
+++ b/VS2012/civetweb_lua/civetweb_lua.vcxproj
@@ -119,7 +119,7 @@
Level3
Disabled
USE_IPV6;LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- $(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)
+ $(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)
Windows
@@ -133,7 +133,7 @@
Level3
Disabled
USE_IPV6;LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;CONSOLE;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- $(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)
+ $(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)
Console
@@ -177,7 +177,7 @@
true
true
USE_IPV6;LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
- $(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)
+ $(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)
Windows
@@ -209,6 +209,7 @@
+
diff --git a/VS2012/civetweb_lua/civetweb_lua.vcxproj.filters b/VS2012/civetweb_lua/civetweb_lua.vcxproj.filters
index 504327e4..db2f8d3d 100644
--- a/VS2012/civetweb_lua/civetweb_lua.vcxproj.filters
+++ b/VS2012/civetweb_lua/civetweb_lua.vcxproj.filters
@@ -30,6 +30,9 @@
Header Files
+
+ Header Files
+
@@ -60,4 +63,4 @@
inl files
-
+
\ No newline at end of file
diff --git a/src/mod_lua.inl b/src/mod_lua.inl
index 3df08bae..a0f5d680 100644
--- a/src/mod_lua.inl
+++ b/src/mod_lua.inl
@@ -1,29 +1,7 @@
-#include
-#include
+#include "civetweb_lua.h"
+
#include "lua_civet.h"
-#ifndef LUA_VERSION_NUM
-#error "Unknown Lua version"
-
-#elif LUA_VERSION_NUM == 501
-/* Lua 5.1 detected */
-#define LUA_OK 0
-#define LUA_ERRGCMM 999 /* not supported */
-#define mg_lua_load(a,b,c,d,e) lua_load(a,b,c,d)
-#define lua_rawlen lua_objlen
-#define lua_newstate(a, b) luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
-
-#elif LUA_VERSION_NUM == 502
-/* Lua 5.2 detected */
-#define mg_lua_load lua_load
-
-#elif LUA_VERSION_NUM == 503
-/* Lua 5.3 detected */
-#define mg_lua_load lua_load
-
-#endif
-
-
#ifdef _WIN32
static void *
mmap(void *addr, int64_t len, int prot, int flags, int fd, int offset)
diff --git a/src/third_party/civetweb_lua.h b/src/third_party/civetweb_lua.h
new file mode 100644
index 00000000..3e3c322b
--- /dev/null
+++ b/src/third_party/civetweb_lua.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2015 the Civetweb developers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+ /* This header is intended to support Lua 5.1, Lua 5.2 and Lua 5.3 in the same
+ * C source code.
+ */
+
+#ifndef CIVETWEB_LUA_H
+#define CIVETWEB_LUA_H
+
+#define LUA_LIB
+#include "lua.h"
+#include "lauxlib.h"
+#include "lualib.h"
+
+#ifndef LUA_VERSION_NUM
+#error "Unknown Lua version"
+
+#elif LUA_VERSION_NUM == 501
+/* Lua 5.1 detected */
+#define LUA_OK 0
+#define LUA_ERRGCMM 999 /* not supported */
+#define mg_lua_load(a,b,c,d,e) lua_load(a,b,c,d)
+#define lua_rawlen lua_objlen
+#define lua_newstate(a, b) luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
+#define lua_pushinteger lua_pushnumber
+
+#elif LUA_VERSION_NUM == 502
+/* Lua 5.2 detected */
+#define mg_lua_load lua_load
+
+#elif LUA_VERSION_NUM == 503
+/* Lua 5.3 detected */
+#define mg_lua_load lua_load
+
+#endif
+
+#endif /* #ifndef CIVETWEB_LUA_H */
diff --git a/src/third_party/lfs.c b/src/third_party/lfs.c
index 4ffbbd79..03ec4e67 100644
--- a/src/third_party/lfs.c
+++ b/src/third_party/lfs.c
@@ -64,9 +64,7 @@
#include
#endif
-#include
-#include
-#include
+#include "civetweb_lua.h"
#include "lfs.h"
diff --git a/src/third_party/lsqlite3.c b/src/third_party/lsqlite3.c
index 0bfc54ae..32e7134b 100644
--- a/src/third_party/lsqlite3.c
+++ b/src/third_party/lsqlite3.c
@@ -30,13 +30,7 @@
#include
#include
-#define LUA_LIB
-#include "lua.h"
-#include "lauxlib.h"
-
-#if LUA_VERSION_NUM == 501
-#define lua_pushinteger lua_pushnumber
-#endif
+#include "civetweb_lua.h"
#if LUA_VERSION_NUM > 501
/*