snapframework / io-streams-haproxy

HAProxy protocol v1.5 support for io-streams
BSD 3-Clause "New" or "Revised" License
7 stars 17 forks source link

Build fails #5

Closed mantkiew closed 9 years ago

mantkiew commented 9 years ago

GHC 7.8.3, Cabal 1.20, Haskell Platform 2014.2.0.0, Windows

Error:

Configuring io-streams-haproxy-1.0.0.0...
Building io-streams-haproxy-1.0.0.0...
Failed to install io-streams-haproxy-1.0.0.0
Build log ( C:\projects\snap\.sandbox\logs\io-streams-haproxy-1.0.0.0.log ):
Building io-streams-haproxy-1.0.0.0...
Preprocessing library io-streams-haproxy-1.0.0.0...
[2 of 2] Compiling System.IO.Streams.Network.HAProxy ( src\System\IO\Streams\Network\HAProxy.hs, dist\dist-sandbox-d77347ee\build\System\IO\Streams\Network\HAProxy.o )

src\System\IO\Streams\Network\HAProxy.hs:320:18:
    Not in scope: data constructor `N.SockAddrUnix'
    Perhaps you meant one of these:
      `N.SockAddrInet' (imported from Network.Socket),
      `N.SockAddrInet6' (imported from Network.Socket)

src\System\IO\Streams\Network\HAProxy.hs:321:18:
    Not in scope: data constructor `N.SockAddrUnix'
    Perhaps you meant one of these:
      `N.SockAddrInet' (imported from Network.Socket),
      `N.SockAddrInet6' (imported from Network.Socket)

src\System\IO\Streams\Network\HAProxy.hs:350:19:
    Not in scope: data constructor `N.SockAddrUnix'
    Perhaps you meant one of these:
      `N.SockAddrInet' (imported from Network.Socket),
      `N.SockAddrInet6' (imported from Network.Socket)
cabal.exe: Error: some packages failed to install:
io-streams-haproxy-1.0.0.0 failed during the building phase. The exception
was:
ExitFailure 1
gregorycollins commented 9 years ago

Please confirm the fix? I don't have a Windows machine.

mantkiew commented 9 years ago

Just pulled and built. Unfortunately, I am still getting the same error. I tried GHCi like this:

Prelude> :m + Network.Socket
Prelude Network.Socket> :i SockAddr
data SockAddr
  = SockAddrInet PortNumber HostAddress
  | SockAddrInet6 PortNumber FlowInfo HostAddress6 ScopeID
        -- Defined in `network-2.6.0.2:Network.Socket.Types'
instance Eq SockAddr
  -- Defined in `network-2.6.0.2:Network.Socket.Types'
instance Ord SockAddr
  -- Defined in `network-2.6.0.2:Network.Socket.Types'
instance Show SockAddr -- Defined in `Network.Socket'

As you can see, the SockAddrUnix is simply undefined on Windows!!! Weird that Haddocks do not mention anything about it.

I tried building using both MSYS and PowerShell.

I think the answer to this SO question will help.

mantkiew commented 9 years ago

So, I added the following to the library section:

library
   if os(windows)
    cpp-options:       -DWINDOWS
  hs-source-dirs:    src
...

and the previous error does not appear anymore (the ifndef WINDOWS worked). However, now I am getting another error:

cbits\byteorder.c:5:23:
     fatal error: arpa/inet.h: No such file or directory
compilation terminated.

See another SO answer - on Windows, one must use winsock2.h instead of inet.h.

See network's HsNet.h for inspiration.

gregorycollins commented 9 years ago

Just send a pull request? I'd need you to verify any fix anyways.

mantkiew commented 9 years ago

Sent pull request #6.