2

So I'm trying to use Luasocket with a third-party game that has a Lua API. It has support for packages but it says it needs some luasocket files I don't have (though it works outside of the IDE because I have Luasocket installed in the lua directory). These seem to be core.dll, core.lua and core/init.lua. I assume I get these by compiling Luasocket.

I tried that with very little success. The scripts for building luasocket that I find always give me errors. How am I supposed to get these files and compile them?

EDIT: Here is the error Cygwin gives me when I try to build Luasocket:

src/wsocket.c: In function ‘socket_open’:
src/wsocket.c:19:5: error: unknown type name ‘WSADATA’
     WSADATA wsaData;
     ^
src/wsocket.c:20:5: error: unknown type name ‘WORD’
     WORD wVersionRequested = MAKEWORD(2, 0);
     ^
src/wsocket.c:23:24: error: request for member ‘wVersion’ in something not a structure or union
     if ((LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 0) &&
                        ^
src/wsocket.c:23:57: error: request for member ‘wVersion’ in something not a structure or union
     if ((LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 0) &&
                                                         ^
src/wsocket.c:24:24: error: request for member ‘wVersion’ in something not a structure or union
         (LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1)) {
                        ^
src/wsocket.c:24:57: error: request for member ‘wVersion’ in something not a structure or union
         (LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1)) {
                                                         ^
src/wsocket.c: In function ‘socket_select’:
src/wsocket.c:82:16: error: ‘DWORD’ undeclared (first use in this function)
         Sleep((DWORD) (1000*t));
                ^
src/wsocket.c:82:16: note: each undeclared identifier is reported only once for each function it appears in
src/wsocket.c: In function ‘socket_connect’:
src/wsocket.c:127:16: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
     if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err;
                ^
src/wsocket.c:127:41: error: ‘WSAEINPROGRESS’ undeclared (first use in this function)
     if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err;
                                         ^
src/wsocket.c: In function ‘socket_accept’:
src/wsocket.c:180:20: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
         if (err != WSAEWOULDBLOCK && err != WSAECONNABORTED) return err;
                    ^
src/wsocket.c:180:45: error: ‘WSAECONNABORTED’ undeclared (first use in this function)
         if (err != WSAEWOULDBLOCK && err != WSAECONNABORTED) return err;
                                             ^
src/wsocket.c: In function ‘socket_send’:
src/wsocket.c:211:20: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
         if (err != WSAEWOULDBLOCK) return err;
                    ^
src/wsocket.c: In function ‘socket_sendto’:
src/wsocket.c:233:20: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
         if (err != WSAEWOULDBLOCK) return err;
                    ^
src/wsocket.c: In function ‘socket_recv’:
src/wsocket.c:259:20: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
         if (err != WSAEWOULDBLOCK) {
                    ^
src/wsocket.c:260:24: error: ‘WSAECONNRESET’ undeclared (first use in this function)
             if (err != WSAECONNRESET || prev == WSAECONNRESET) return err;
                        ^
src/wsocket.c: In function ‘socket_recvfrom’:
src/wsocket.c:288:20: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
         if (err != WSAEWOULDBLOCK) {
                    ^
src/wsocket.c:289:24: error: ‘WSAECONNRESET’ undeclared (first use in this function)
             if (err != WSAECONNRESET || prev == WSAECONNRESET) return err;
                        ^
src/wsocket.c: In function ‘socket_hoststrerror’:
src/wsocket.c:333:14: error: ‘WSAHOST_NOT_FOUND’ undeclared (first use in this function)
         case WSAHOST_NOT_FOUND: return "host not found";
              ^
src/wsocket.c: In function ‘socket_strerror’:
src/wsocket.c:341:14: error: ‘WSAEADDRINUSE’ undeclared (first use in this function)
         case WSAEADDRINUSE: return "address already in use";
              ^
src/wsocket.c:342:14: error: ‘WSAECONNREFUSED’ undeclared (first use in this function)
         case WSAECONNREFUSED: return "connection refused";
              ^
src/wsocket.c:343:14: error: ‘WSAEISCONN’ undeclared (first use in this function)
         case WSAEISCONN: return "already connected";
              ^
src/wsocket.c:344:14: error: ‘WSAEACCES’ undeclared (first use in this function)
         case WSAEACCES: return "permission denied";
              ^
src/wsocket.c:345:14: error: ‘WSAECONNABORTED’ undeclared (first use in this function)
         case WSAECONNABORTED: return "closed";
              ^
src/wsocket.c:346:14: error: ‘WSAECONNRESET’ undeclared (first use in this function)
         case WSAECONNRESET: return "closed";
              ^
src/wsocket.c:347:14: error: ‘WSAETIMEDOUT’ undeclared (first use in this function)
         case WSAETIMEDOUT: return "timeout";
              ^
src/wsocket.c: In function ‘wstrerror’:
src/wsocket.c:359:14: error: ‘WSAEINTR’ undeclared (first use in this function)
         case WSAEINTR: return "Interrupted function call";
              ^
src/wsocket.c:360:14: error: ‘WSAEACCES’ undeclared (first use in this function)
         case WSAEACCES: return "Permission denied";
              ^
src/wsocket.c:361:14: error: ‘WSAEFAULT’ undeclared (first use in this function)
         case WSAEFAULT: return "Bad address";
              ^
src/wsocket.c:362:14: error: ‘WSAEINVAL’ undeclared (first use in this function)
         case WSAEINVAL: return "Invalid argument";
              ^
src/wsocket.c:363:14: error: ‘WSAEMFILE’ undeclared (first use in this function)
         case WSAEMFILE: return "Too many open files";
              ^
src/wsocket.c:364:14: error: ‘WSAEWOULDBLOCK’ undeclared (first use in this function)
         case WSAEWOULDBLOCK: return "Resource temporarily unavailable";
              ^
src/wsocket.c:365:14: error: ‘WSAEINPROGRESS’ undeclared (first use in this function)
         case WSAEINPROGRESS: return "Operation now in progress";
              ^
src/wsocket.c:366:14: error: ‘WSAEALREADY’ undeclared (first use in this function)
         case WSAEALREADY: return "Operation already in progress";
              ^
src/wsocket.c:367:14: error: ‘WSAENOTSOCK’ undeclared (first use in this function)
         case WSAENOTSOCK: return "Socket operation on nonsocket";
              ^
src/wsocket.c:368:14: error: ‘WSAEDESTADDRREQ’ undeclared (first use in this function)
         case WSAEDESTADDRREQ: return "Destination address required";
              ^
src/wsocket.c:369:14: error: ‘WSAEMSGSIZE’ undeclared (first use in this function)
         case WSAEMSGSIZE: return "Message too long";
              ^
src/wsocket.c:370:14: error: ‘WSAEPROTOTYPE’ undeclared (first use in this function)
         case WSAEPROTOTYPE: return "Protocol wrong type for socket";
              ^
src/wsocket.c:371:14: error: ‘WSAENOPROTOOPT’ undeclared (first use in this function)
         case WSAENOPROTOOPT: return "Bad protocol option";
              ^
src/wsocket.c:372:14: error: ‘WSAEPROTONOSUPPORT’ undeclared (first use in this function)
         case WSAEPROTONOSUPPORT: return "Protocol not supported";
              ^
src/wsocket.c:373:14: error: ‘WSAESOCKTNOSUPPORT’ undeclared (first use in this function)
         case WSAESOCKTNOSUPPORT: return "Socket type not supported";
              ^
src/wsocket.c:374:14: error: ‘WSAEOPNOTSUPP’ undeclared (first use in this function)
         case WSAEOPNOTSUPP: return "Operation not supported";
              ^
src/wsocket.c:375:14: error: ‘WSAEPFNOSUPPORT’ undeclared (first use in this function)
         case WSAEPFNOSUPPORT: return "Protocol family not supported";
              ^
src/wsocket.c:376:14: error: ‘WSAEAFNOSUPPORT’ undeclared (first use in this function)
         case WSAEAFNOSUPPORT:
              ^
src/wsocket.c:378:14: error: ‘WSAEADDRINUSE’ undeclared (first use in this function)
         case WSAEADDRINUSE: return "Address already in use";
              ^
src/wsocket.c:379:14: error: ‘WSAEADDRNOTAVAIL’ undeclared (first use in this function)
         case WSAEADDRNOTAVAIL: return "Cannot assign requested address";
              ^
src/wsocket.c:380:14: error: ‘WSAENETDOWN’ undeclared (first use in this function)
         case WSAENETDOWN: return "Network is down";
              ^
src/wsocket.c:381:14: error: ‘WSAENETUNREACH’ undeclared (first use in this function)
         case WSAENETUNREACH: return "Network is unreachable";
              ^
src/wsocket.c:382:14: error: ‘WSAENETRESET’ undeclared (first use in this function)
         case WSAENETRESET: return "Network dropped connection on reset";
              ^
src/wsocket.c:383:14: error: ‘WSAECONNABORTED’ undeclared (first use in this function)
         case WSAECONNABORTED: return "Software caused connection abort";
              ^
src/wsocket.c:384:14: error: ‘WSAECONNRESET’ undeclared (first use in this function)
         case WSAECONNRESET: return "Connection reset by peer";
              ^
src/wsocket.c:385:14: error: ‘WSAENOBUFS’ undeclared (first use in this function)
         case WSAENOBUFS: return "No buffer space available";
              ^
src/wsocket.c:386:14: error: ‘WSAEISCONN’ undeclared (first use in this function)
         case WSAEISCONN: return "Socket is already connected";
              ^
src/wsocket.c:387:14: error: ‘WSAENOTCONN’ undeclared (first use in this function)
         case WSAENOTCONN: return "Socket is not connected";
              ^
src/wsocket.c:388:14: error: ‘WSAESHUTDOWN’ undeclared (first use in this function)
         case WSAESHUTDOWN: return "Cannot send after socket shutdown";
              ^
src/wsocket.c:389:14: error: ‘WSAETIMEDOUT’ undeclared (first use in this function)
         case WSAETIMEDOUT: return "Connection timed out";
              ^
src/wsocket.c:390:14: error: ‘WSAECONNREFUSED’ undeclared (first use in this function)
         case WSAECONNREFUSED: return "Connection refused";
              ^
src/wsocket.c:391:14: error: ‘WSAEHOSTDOWN’ undeclared (first use in this function)
         case WSAEHOSTDOWN: return "Host is down";
              ^
src/wsocket.c:392:14: error: ‘WSAEHOSTUNREACH’ undeclared (first use in this function)
         case WSAEHOSTUNREACH: return "No route to host";
              ^
src/wsocket.c:393:14: error: ‘WSAEPROCLIM’ undeclared (first use in this function)
         case WSAEPROCLIM: return "Too many processes";
              ^
src/wsocket.c:394:14: error: ‘WSASYSNOTREADY’ undeclared (first use in this function)
         case WSASYSNOTREADY: return "Network subsystem is unavailable";
              ^
src/wsocket.c:395:14: error: ‘WSAVERNOTSUPPORTED’ undeclared (first use in this function)
         case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range";
              ^
src/wsocket.c:396:14: error: ‘WSANOTINITIALISED’ undeclared (first use in this function)
         case WSANOTINITIALISED:
              ^
src/wsocket.c:398:14: error: ‘WSAEDISCON’ undeclared (first use in this function)
         case WSAEDISCON: return "Graceful shutdown in progress";
              ^
src/wsocket.c:399:14: error: ‘WSAHOST_NOT_FOUND’ undeclared (first use in this function)
         case WSAHOST_NOT_FOUND: return "Host not found";
              ^
src/wsocket.c:400:14: error: ‘WSATRY_AGAIN’ undeclared (first use in this function)
         case WSATRY_AGAIN: return "Nonauthoritative host not found";
              ^
src/wsocket.c:401:14: error: ‘WSANO_RECOVERY’ undeclared (first use in this function)
         case WSANO_RECOVERY: return "Nonrecoverable name lookup error";
              ^
src/wsocket.c:402:14: error: ‘WSANO_DATA’ undeclared (first use in this function)
         case WSANO_DATA: return "Valid name, no data record of requested type";
              ^
Error: failed to build LuaSocket
greatwolf
  • 20,287
  • 13
  • 71
  • 105
lordnoob
  • 190
  • 12
  • Can you not just use the copies you already have installed by putting them where the game is looking for them? – Etan Reisner Jan 13 '15 at 20:59
  • I tried that, but a) it requests files that I can't find in the installation, and b) I think they're of a different version (I have an older version of Luasocket I believe) or something, because the server crashes when I add core.dll where it is requested. Either way, I'd like to compile Luasocket just to explore all avenues – lordnoob Jan 13 '15 at 21:08
  • What files can't you find? What version do you have? The version of luasocket itself likely matters less than the version of lua the application is expecting (and the version of lua that luasocket was built for). – Etan Reisner Jan 13 '15 at 21:14
  • The application expects files for lua 5.2. I got the latest one from Github (luasocket 3.0-rc1), however the files I gave it are for 2.0.2, the version of LuaSocket that came with Lua For Windows. I would gladly compile the newer ones, but trying to gives me the above error (and using the old core.dll makes the game crash). And so, this is my question. **How can I compile it**? LuaRocks also gives me an error. Unfortunately, this release of LuaSocket is, according to the changelog, the one that added Lua 5.2 compatibility, which the app uses, so I have to use it. Thanks in advance – lordnoob Jan 13 '15 at 21:31
  • 1
    I could see how that could lead to problems. The LuaSocket that comes with LFW is likely for Lua 5.1. That means when you load that `core.dll` it's also going to try and pull `lua51.dll`into the running process which means you end up with both `lua52.dll` and `lua51.dll` getting mixed together. – greatwolf Jan 13 '15 at 22:38

1 Answers1

0

This SO answer may help. It provides details on how to compile using gcc as well as references to build scripts I use and compiled binaries for luasocket 3.0-rc1 and Lua 5.2.

Community
  • 1
  • 1
Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56