Binding C ++ dll with Haskell-Platform on Windows, outputs 'undefined reference'

I am a Haskell enthusiast and am stuck in compiling my little Haskell program on Windows. My program uses the iconv package, which in turn uses an external library written in c / C ++. To do the job, I:

  • Launch GNU-Iconv and add the bin folder, where libiconv-2.dll and libiconv2.dll are located before the PATH variable.
  • Extracted and copied LibIconv developers files to the "mingw" folder Haskell platform location.
  • Then 'cabal install iconv' compiles and I have the cabal package installed.

Now, when I try to create my module in Leksah, I get the following message from the GHC:

 Building norms-parser-0.0.1... Linking dist\build\norms-parser\norms-parser.exe ... C:\Documents and Settings\kdv\Application Data\cabal\iconv-0.4.1.0\ghc-7.0.4/libHSiconv-0.4.1.0.a(hsiconv.o):hsiconv.c:(.text+0x7): undefined reference to `_imp__libiconv_open' C:\Documents and Settings\kdv\Application Data\cabal\iconv-0.4.1.0\ghc-7.0.4/libHSiconv-0.4.1.0.a(hsiconv.o):hsiconv.c:(.text+0x17): undefined reference to `_imp__libiconv' C:\Documents and Settings\kdv\Application Data\cabal\iconv-0.4.1.0\ghc-7.0.4/libHSiconv-0.4.1.0.a(hsiconv.o):hsiconv.c:(.text+0x27): undefined reference to `_imp__libiconv_close' collect2: ld returned 1 exit status 

With "GHCi" I also run into a problem:

 ghc.exe: unable to load package `iconv-0.4.1.0' ghc.exe: C:\Documents and Settings\kdv\Application Data\cabal\iconv-0.4.1.0\ghc- 7.0.4\HSiconv-0.4.1.0.o: unknown symbol `__imp__libiconv_open' 

I think the likely solution is to properly configure the c / C ++ header files in the "mingw" folder and set the PATH variables to the "lib" files, but I know little about it, so any help would be greatly appreciated.

+5
source share
1 answer

Installing libiconv is a bit complicated on Windows.

  • Download libconv binaries and developer files from here this site
  • Unzip both packages through the mingw folder located in the Haskell platform folder.
  • Download cabal package for Iconv latest version at the moment
  • Modify the iconv.cabal file so the lines with include-dirs and extra-lib-dirs will look like

     include-dirs: cbits, "C:\\HaskellPlatform\\2013.2.0.0\\mingw\\include" extra-lib-dirs: "C:\\HaskellPlatform\\2013.2.0.0\\mingw\\lib" 

notice the double strokes on the way to the window and edit it on your way to the Haskell platform.

  • Edit the iconv.cabal file, there is a line with if os(darwin) || os(freebsd) if os(darwin) || os(freebsd) , change it to if os(darwin) || os(freebsd) || os(windows) if os(darwin) || os(freebsd) || os(windows)
  • Here it is, now you can run the cabal install command from iconv pachage dir
+1
source

Source: https://habr.com/ru/post/954009/


All Articles