3

I'm a total newb with haskell and I'm making a trivial project but I needed to run cabal install encoding. But, when I did, it gave me this error:

Configuring encoding-0.6.7.2...
setup.exe: Missing dependency on a foreign library:
* Missing (or bad) header file: system_encoding.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.
cabal.exe: Error: some packages failed to install:
encoding-0.6.7.2 failed during the configure step. The exception was:
ExitFailure 1

How do fix this problem?

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

1 Answers1

1

TL;DR: cabal install encoding -f-systemencoding


I found a few forum posts on this topic. The most important thing said was

The missing header is langinfo.h - where it originates I don't know, as I don't have it with either Msys/MinGW or Cygwin and my Cygwin is pretty large these days.

From there, I looked on the Cygwin website for where langinfo.h is. Turns out it comes with the default install of Cygwin. And this is its path:

usr/include/langinfo.h

So I installed Cygwin, (actually I already had it installed) and then I ran cabal install like this:

cabal install encoding --extra-include-dirs='C:\cygwin\usr\include'

That registered the package without issue.


Update

Although this does let you register the package, you can't use it. When I tried to GHCi gave me this error:

Loading package encoding-0.6.7.2 ... linking ... ghc: unable to load package `encoding-0.6.7.2'

I am now stuck again.

Update 2

I got some help on IRC from a gentleman named fryguybob. This is another way you can install it: cabal install encoding -f-systemencoding. That worked for me

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
  • 2
    As a general rule, looking at the flags in the cabal file can point to useful ways to avoid needing external libraries potentially at the cost of some of the API or some feature. Glad I could help! – fryguybob Mar 15 '13 at 12:26
  • @fryguybob: How do you look at it? – Daniel Kaplan Mar 15 '13 at 16:47
  • 1
    There is a link at the bottom of the hackage page to "package description" that opens the cabal file. You can also do `cabal unpack ...` and that will extract the package into a directory where you can view the source. `cabal info ...` will also list the flags, but not much information about what they do. – fryguybob Mar 15 '13 at 17:25