5

I am trying to compile Network.HTTP (http://hackage.haskell.org/package/network) on win32/cygwin. However, it does fail with following message:

Setup.hs: Missing dependency on a foreign library:
* Missing (or bad) header file: HsNet.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

Unfortuntely it does not give more clues. The HsNet.h includes sys/uio.h which, actually should not be included, and should be configurered correctly.

Yogesh Sajanikar
  • 1,086
  • 7
  • 19

3 Answers3

3

Don't use cygwin, instead follow Johan Tibells way

Installing MSYS

Install the latest Haskell Platform. Use the default settings.

Download version 1.0.11 of MSYS. You'll need the following files:
    MSYS-1.0.11.exe
    msysDTK-1.0.1.exe
    msysCORE-1.0.11-bin.tar.gz

The files are all hosted on haskell.org as they're quite hard to find in the official MinGW/MSYS repo.

Run MSYS-1.0.11.exe followed by msysDTK-1.0.1.exe. The former asks you if you want to run a normalization step. You can skip that.

Unpack msysCORE-1.0.11-bin.tar.gz into C:\msys\1.0. Note that you can't do that using an MSYS shell, because you can't overwrite the files in use, so make a copy of C:\msys\1.0, unpack it there, and then rename the copy back to C:\msys\1.0.

Add C:\Program Files\Haskell Platform\VERSION\mingw\bin to your PATH. This is neccesary if you ever want to build packages that use a configure script, like network, as configure scripts need access to a C compiler.

These steps are what Tibell uses to compile the Network package for win and I have used this myself successfully several times on most of the haskell platform releases.

Jonke
  • 6,525
  • 2
  • 25
  • 40
1

It is possible to build network on win32/cygwin. And the above steps, though useful (by Jonke) may not be necessary.

While doing the configuration step, specify

runghc Setup.hs configure  --configure-option="--build=mingw32"

So that the library is configured for mingw32, else you will get link or "undefined references" if you try to link or use network library.

Yogesh Sajanikar
  • 1,086
  • 7
  • 19
1

This combined with @Yogesh Sajanikar's answer made it work for me (on win64/cygwin):

  • Make sure the gcc on your path is NOT the Mingw/Cygwin one, but the C:\ghc\ghc-6.12.1\mingw\bin\gcc.exe

(Run

export PATH="/cygdrive/.../ghc-7.8.2/mingw/bin:$PATH" 

before running cabal install network in the Cygwin shell)

FunctorSalad
  • 2,502
  • 25
  • 20