Search code examples
luacompiler-errorsluasocketluarocks

LuaRocks LuaSocket failed install


Disclaimer: There is a similar question on here by a different user, but it was never answered. Maybe this time will be different.

I'm attempting to install Copas, but one of the dependencies is LuaSocket. However, when I try to install LuaSocket, I get the following error:

src/wsocket.c: In function 'socket_gaistrerror':
src/wsocket.c:417:14: error: 'ERROR_NOT_ENOUGH_MEMORY' undeclared (first use in this function)
         case EAI_MEMORY: return "memory allocation failure";
              ^
src/wsocket.c:417:14: note: each undeclared identifier is reported only once for each function it appears in

Error: Build error: Failed compiling object src/wsocket.o

I've tried downloading the rockspec and installing it there, I've tried the luarocks site as well as the github site, and I've tried different versions. My Lua compiler is Lua for Windows and Lua version is 5.1. I'm using MinGW for the C compiler. All this is on a Windows 10 laptop.


Solution

  • It seems like it may depend on the version of mingw you are using; this discussion of the same error in curl may help with identifying the issue and the proposed resolution/workaround. From the discussion it looks like adding -DENABLE_INET_PTON=OFF or using MinGW64-w64 v7+ may resolve the issue.

    Also, Lua for Windows should already include luasocket, so I'm not sure why it would need to be compiled.