I had installed Lua 5.1 using LuaForWindows, but I don't see luasocket.h in what was installed, so it appears I can't use that from my Visual Studio C++ project.
So, I am trying to build and I got the latest version from github for Lua 5.2, even though it is in development as I can't find the source for Lua 5.1 from sourceforge.
When I go to http://luaforge.net/projects/luasocket/ it brings me back to the LuaSocket page.
So, I have built Lua 5.2.2 and this is my build.bat for luasocket:
set INCLUDE=%INCLUDE%;C:\Users\me\Downloads\lua-5.2.2\src
echo %INCLUDE%
set LIB=%LIB%;C:\Users\me\Downloads\lua-5.2.2\src
echo %LIB%
ren unix.c unix.c00
ren usocket.c usocket.c00
cl /MD /O2 /W3 /c /nologo /DWIN32_LEAN_AND_MEAN *.c
ren mime.obj mime.o
link /DLL /OUT:socket.dll /base:0x67800000 /export:luaopen_socket_core *.obj mime.o msvcrt.lib lua5.2.lib wsock32.lib
link /DLL /OUT:mime.dll /base:0x67700000 /export:luaopen_mime_core mime.o msvcrt.lib lua5.2.lib
The biggest problem is that luaL_openlib undefined
appears when trying to compile some of the c files and _luaL_openlib
is an unresolved external symbol referenced, but these are related issues.
I currently don't care if I use Lua 5.1 or 5.2, but I need to be able to use LuaSocket, so is there a way to use it from LuaForWindows (https://code.google.com/p/luaforwindows/) or is there a problem with my build.bat that will fix my problem?
(Updated on 10/2/2015) The changes described earlier have been merged into luasocket master branch, which compiles with Lua 5.2 on Windows.
(previous version of the answer, which is no longer applicable)
You need to use this branch if you want to compile luasocket with Lua 5.2. It includes a solution file for VisualStudio.
I haven't compiled this branch with VisualStudio, but I did compile it with mingw and used it with Lua 5.2 on Windows.
Here is the list of build flags I have for mingw: BUILD_FLAGS="-Wl,-s -O2 -shared -D LUA_COMPAT_MODULE -D IPV6_V6ONLY=27 -D WINVER=0x0501 -s
; I also link with -lwsock32 -lws2_32 -llua
.
In your case I don't see LUA_COMPAT_MODULE
, which is currently required by luasocket and also don't see ws2_32
on the list of libraries.
I also ran into missing inet_ntop
and inet_pton
calls, so I patched luasocket to include those (not sure if this an issue for VS as well). You may want to try compiling with this branch: https://github.com/pkulchenko/luasocket/commits/lua52-mingw.