在Windows上将c ++ dll与Haskell-Platform链接起来,输出'未定义参考' [英] Linking c++ dll with Haskell-Platform on Windows, outputs 'undefined reference'
问题描述
我是一名Haskell爱好者,在Windows上编译我的小Haskell程序时遇到困难。我的程序使用 iconv 软件包,该软件包反过来使用用c / c ++编写的外文库。为了使事情有效,我有:
- 运行 GNU-Iconv 安装程序,并将
'libiconv-2.dll'和'libiconv2.dll'的'bin'文件夹添加到
变量。 - 提取并复制'LibIconv开发者文件'到
Haskell平台位置的'mingw'文件夹中。 - 然后'cabal install iconv'编译并安装了cabal软件包
。
现在,当我尝试在Leksah中构建我的模块时,我收到'GHC'的以下消息:
Building norms-parser-0.0.1 ...
链接dist\build\\\
orms-parser\\\
orms-parser.exe ...
C:\Documents and Settings\kdv\应用程序数据\cabal\iconv-0.4.1.0\ghc-7.0.4 / libHSiconv-0.4.1.0.a(hsiconv.o):hsiconv.c :(。text + 0x7):未定义的引用_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):未定义引用'_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):对`_imp__libiconv_close'的未定义引用
collect2:ld返回1退出状态
使用'GHCi',我也面临一个问题:
ghc.exe:无法加载软件包`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:未知符号`__imp__libiconv_open'
我认为可能的解决方案是将c / c ++头文件正确设置为'mingw'文件夹并将PATH变量设置为'lib'文件,但是我点亮了有关它的知识,所以任何帮助将非常感谢。
解决方案在Windows上安装libiconv有点棘手。 >
- 从二进制和开发者文件 .sourceforge.net / packages / libiconv.htmrel =nofollow>它位于此处
- 将这两个软件包解压缩到位于Haskell Platform文件夹内的mingw文件夹中。
- 下载Iconv的cabal软件包目前的最新版本
编辑iconv.cabal文件,所以包含
include-dirs
和extra-lib-dirs
看起来像include-dirs:cbits,C:\ \HaskellPlatform\\\2013.2.0.0\\\\\\\\\\\\\\\包括
extra-lib-dirs:C:\\HaskellPlatform\\\2013.2.0.0\\ mingw\\ lib
注意在Windows路径中的双破折号,并编辑它到你的Haskell平台的路径。
- 编辑iconv.cabal文件,有一行
如果os(达尔文)|| os(freebsd)
,将其更改为if os(darwin)|| os(freebsd)|| os(windows)
- 就是这样,现在你可以在iconv中运行
cabal install
命令pachage dir
I am a Haskell enthusiast and have got stuck upon compiling my little Haskell program on Windows. My program uses the iconv package, which in turn uses the foreign library written in c/c++. To make things work I have :
- Run GNU-Iconv setup and added its 'bin' folder, where
'libiconv-2.dll' and 'libiconv2.dll' are located, to the
PATH
variable. - Extracted and copied 'LibIconv developer files' to the 'mingw' folder of Haskell Platform location.
- Then 'cabal install iconv' compiles and I have the cabal package installed.
Now, when I try to build my module in Leksah, I get the following message from '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 face an issue too:
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 probable solution is in having the right setup of c/c++ header files to 'mingw' folder and setting PATH variables to 'lib' files, but I have little knowledge about it, so any help will be much appreciated.
Installing libiconv is a little tricky on Windows.
- Download libiconv binary and developer files from it site here
- Unzip both packages over mingw folder, which is inside your Haskell Platform folder.
- Download cabal package for Iconv latest version for the moment
Edit iconv.cabal file, so lines with
include-dirs
andextra-lib-dirs
will looks likeinclude-dirs: cbits, "C:\\HaskellPlatform\\2013.2.0.0\\mingw\\include" extra-lib-dirs: "C:\\HaskellPlatform\\2013.2.0.0\\mingw\\lib"
notice the double dashes in windows path, and edit it to your path of Haskell Platform.
- Edit iconv.cabal file, there is a line with
if os(darwin) || os(freebsd)
, change it toif os(darwin) || os(freebsd) || os(windows)
- Thats it, now you can run
cabal install
command from iconv pachage dir
这篇关于在Windows上将c ++ dll与Haskell-Platform链接起来,输出'未定义参考'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!