Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a Haskell program depending on iconv under windows

I have a project depending on iconv, because I need to work with cp1251 codepage. Here is the minimal implementation of the problem project. I has installed iconv from here and successfully installed haskell package "iconv" like this

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

The package iconv is properly installed, but the project depending on it failed on linking, here is what is going on.

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>

Why is iconv installed and linked but iconvsmpl can not be linked. How to build it under Windows? Is there another way to work with foreign encodings under Windows for Haskell ?

It is very desirable to have executable for windows. Package building and working under Linux.

The version of Haskell-Platform is 2013.2.0.0

like image 304
s9gf4ult Avatar asked Sep 17 '13 17:09

s9gf4ult


1 Answers

You'll need to modify the iconv package's .cabal file when installing on Windows. Remove the conditional check so that the extra-libraries field always applies. Update the include-dirs and extra-lib-dirs fields to read as follows:

include-dirs:    cbits, "c:\\GnuWin32\\include"
extra-lib-dirs:  "c:\\GnuWin32\\lib"
like image 94
Michael Steele Avatar answered Oct 14 '22 16:10

Michael Steele