2013-03-15 25 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