2013-03-15 17 views
1

我是一个Haskell总新手,我正在做一个小项目,但我需要运行cabal install encoding。但是,当我这样做,它给了我这个错误:在Haskell中,如何在Windows上安装编码包?

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 

如何解决这个问题?

回答

1

TL; DR:cabal install encoding -f-systemencoding


I found a few forum posts on this topic。最重要的事情是

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.

从那里,我看了Cygn的网站langinfo.h是。 Turns out it comes with the default install of Cygwin.这是它的路径:

usr/include/langinfo.h 

So I installed Cygwin,(其实我已经有它安装),然后我跑小集团安装这样的:

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

注册的包没有问题。


更新

虽然这让你注册包,你不能使用它。当我试图GHCi给我这个错误:

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

我现在再次卡住了。

更新2

我上了IRC一些帮助,从绅士命名fryguybob。这是另一种安装方法:cabal install encoding -f-systemencoding。这对我很有用

+2

作为一般规则,查看cabal文件中的标志可以指向有用的方法来避免需要外部库,这可能会牺牲某些API或某些功能。很高兴我能帮上忙! – fryguybob 2013-03-15 12:26:31

+0

@fryguybob:你如何看待它? – 2013-03-15 16:47:35

+1

在hackage页面的底部有一个链接,用于打开cabal文件的“包描述”。你也可以做'cabal unpack ...',然后将这个软件包解压缩到一个可以查看源代码的目录中。 'cabal info ...'也会列出这些标志,但并不包含他们所做的更多信息。 – fryguybob 2013-03-15 17:25:00