根据windows下的iconv构建Haskell程序

时间:2013-09-17 17:20:19

标签: windows haskell linker libraries building

我有一个取决于iconv的项目,因为我需要使用cp1251代码页。 Here is问题项目的最小实施。我已经从here安装了iconv并成功安装了像这样的haskell软件包“iconv”

cabal install iconv --extra-include-dirs="C:\GnuWin32\include" --extra-lib-dirs="C:\GnuWin32\lib"

软件包iconv已正确安装,但依赖于它的项目在链接时失败,以下是正在进行的操作。

c:\iconvsmpl>cabal configure --extra-include-dirs="C:\GnuWin32\include" --extra-
lib-dirs="C:\GnuWin32\lib"
Warning: The package list for 'hackage.haskell.org' is 16 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring iconvsmpl-0.1.0.0...
Warning: The 'license-file' field refers to the file 'LICENSE' which does not
exist.

c:\iconvsmpl>cabal build
Building iconvsmpl-0.1.0.0...
Preprocessing executable 'iconvsmpl' for iconvsmpl-0.1.0.0...
[1 of 1] Compiling Main             ( iconvsmpl.hs, dist\build\iconvsmpl\iconvsm
pl-tmp\Main.o )
Linking dist\build\iconvsmpl\iconvsmpl.exe ...
C:\Users\admin\AppData\Roaming\cabal\iconv-0.4.1.1\ghc-7.6.3/libHSiconv-0.4.1.1.
a(hsiconv.o):hsiconv.c:(.text+0x7): undefined reference to `_imp__libiconv_open'

C:\Users\admin\AppData\Roaming\cabal\iconv-0.4.1.1\ghc-7.6.3/libHSiconv-0.4.1.1.
a(hsiconv.o):hsiconv.c:(.text+0x17): undefined reference to `_imp__libiconv'
C:\Users\admin\AppData\Roaming\cabal\iconv-0.4.1.1\ghc-7.6.3/libHSiconv-0.4.1.1.
a(hsiconv.o):hsiconv.c:(.text+0x27): undefined reference to `_imp__libiconv_clos
e'
collect2: ld returned 1 exit status

c:\iconvsmpl>

为什么安装和链接iconv但无法链接iconvsmpl。如何在Windows下构建它?是否有另一种方法可以在Windows下为Haskell使用外部编码?

非常希望有Windows的可执行文件。打包并在Linux下工作。

Haskell-Platform的版本是2013.2.0.0

1 个答案:

答案 0 :(得分:2)

在Windows上安装时,您需要修改iconv包的.cabal文件。删除条件检查,以便extra-libraries字段始终适用。更新include-dirsextra-lib-dirs字段,如下所示:

include-dirs:    cbits, "c:\\GnuWin32\\include"
extra-lib-dirs:  "c:\\GnuWin32\\lib"