Search code examples
clualuasocket

'SIGPIPE': undeclared identifier in luasocket-2.0.2


I am trying to compile luasocket-2.0.2 (or: luasocket) but as I try to do so, some macros appear to be undefined. Namely:

identifier "SIGPIPE" is undefined
identifier "F_GETFL" is undefined
identifier "O_NONBLOCK" is undefined
identifier "F_SETFL" is undefined

If I google this I see that signal.h has to be included for this. I didn't change the code or anything and as you'd expect, the headers are included:

#include <string.h> 
#include <signal.h>

#include "socket.h"

Not quite sure what I am missing here.

I try to compile this for Windows.

Compiler Flags:

/GS /analyze- /W3 /Zc:wchar_t /I"E:\git\luasocket-2.0.2\../luaext-linker/include" /ZI /Gm /Od /Fd"mime\Debug\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "MIME_EXPORTS" /D "MIME_API=__declspec(dllexport)" /D "_WINDLL" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"mime\Debug\" /EHsc /nologo /Fo"mime\Debug\" /Fp"mime\Debug\mime.pch" 

The errors occur in usocket.c of the socket project:

"SIGPIPE" is undefined  socket  e:\git\luasocket-2.0.2\src\usocket.c    80
... 

Solution

  • Seems like usocket.c is a Unix-specific source.

    /*=========================================================================*\
    * Socket compatibilization module for Unix
    * LuaSocket toolkit
    

    You shouldn't try to include it into Win-targeted builds (unless you are using Cygwin). Also socket.vcxproj doesn't mention this file in the sourceset. That confirms previous suggestion.

    If you've decided to built it via win32.cmd script - correct path to prefix, since script uses hardcoded one:

    make LUAPREFIX_win32='c:\cygwin\home\diego\vc12' LUAV=5.1 PLAT=win32 LUALIBNAME_win32=lualib.lib PLATFORM_win32=Debug install-both