链接 c++ Windows 上的 Haskell-Platform 的 dll 输出“未定义的引用”

发布于 2024-12-28 11:57:52 字数 1539 浏览 3 评论 0原文

我是一名 Haskell 爱好者,并且在 Windows 上编译我的小 Haskell 程序时遇到了困难。我的程序使用 iconv 包,该包又使用用 c/c++ 编写的外部库。为了使事情正常工作,我有:

  • 运行 GNU-Iconv 安装程序并添加其“bin”文件夹, 在哪里 “libiconv-2.dll”和“libiconv2.dll”位于 PATH 多变的。
  • 提取并复制“LibIconv开发人员文件”到“mingw”文件夹 Haskell 平台位置。
  • 然后“cabal install iconv”编译,我就有了 cabal 包 安装。

现在,当我尝试在 Leksah 中构建模块时,我从“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

对于“GHCi”,我也面临一个问题:

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'

我认为可能的解决方案是正确设置 c/c++ 头文件到“mingw”文件夹并将 PATH 变量设置为“lib”文件,但我对此知之甚少,因此任何帮助将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆流 2025-01-04 11:57:52

在 Windows 上安装 libiconv 有点棘手。

  1. it 站点下载 libiconv 二进制开发人员文件这里
  2. 将两个包解压到 mingw 文件夹中,该文件夹位于 Haskell Platform 文件夹内。
  3. 下载 Iconv 的 cabal 包 目前最新版本
  4. 编辑 iconv.cabal文件,因此包含 include-dirsextra-lib-dirs 的行看起来像

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

注意到 Windows 路径中的双破折号,并将其编辑到您的 Haskell Platform 路径。

  1. 编辑 iconv.cabal 文件,有一行 if os(darwin) || os(freebsd),将其更改为 if os(darwin) ||操作系统(freebsd)|| os(windows)
  2. 就是这样,现在您可以从 iconv pachage 目录运行 cabal install 命令

Installing libiconv is a little tricky on Windows.

  1. Download libiconv binary and developer files from it site here
  2. Unzip both packages over mingw folder, which is inside your Haskell Platform folder.
  3. Download cabal package for Iconv latest version for the moment
  4. Edit iconv.cabal file, so lines with include-dirs and extra-lib-dirs will looks 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 dashes in windows path, and edit it to your path of Haskell Platform.

  1. Edit iconv.cabal file, there is a line with if os(darwin) || os(freebsd), change it to if os(darwin) || os(freebsd) || os(windows)
  2. Thats it, now you can run cabal install command from iconv pachage dir
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文