【问题标题】:mkTextEncoding error when running Haskell program compiled on Mac运行在 Mac 上编译的 Haskell 程序时出现 mkTextEncoding 错误
【发布时间】:2012-01-07 06:43:37
【问题描述】:

我正在使用通过 Homebrew 安装的 Haskell Platform 2011.2.0.1。我已经建立了一个已定义相关依赖项的 cabalized 项目。可执行文件只是打印出传递给它的参数。程序编译和链接正确,但是当程序...

Main.hs:

  main = do
    args <- getArgs
    putStrLn "Here are your arguments!:"
    forM_ args putStrLn

...运行,我得到...

跟踪:

$ cabal configure
Resolving dependencies...
Configuring foo-0.1...

$ cabal build
Preprocessing executables for foo-0.1...
Preprocessing test suites for foo-0.1...
Building foo-0.1...

$ dist/build/foobar/foobar some arguments
foobar: mkTextEncoding: failed (Unknown error: 0)
FAIL: 1

我的 PATH 变量的相关部分为:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/usr/X11/bin

我认为这是与libiconv 相关的问题。有任何想法吗?谢谢!

【问题讨论】:

  • 我不是这方面的专家,但 Mac 上的 iconv 问题很常见。据我所知,有两个iconv,一个是系统,一个是macports,它们不兼容,想要一个的东西不能与另一个一起工作。如果你的 google-fu 比我的强,搜索可能会找到可能的解决方案(我没有找到任何东西,但我似乎记得偶尔发布在邮件列表上的修复策略)。
  • @DanielFischer 是正确的,尽管问题通常在链接期间出现。 iconv 问题的普遍接受的解决方案是在配置时添加此标志:--extra-lib-dir=/usr/lib。然后cabal会先找到系统iconv。除非您还链接到需要 macports iconv 的库(许多库将 iconv 作为依赖项,但似乎很少有人真正使用它),否则此方法有效。更多信息请访问blog.omega-prime.co.uk/?p=96。我个人更喜欢第三种解决方案(自编译 GHC)。但是你甚至需要 macports 吗?
  • 感谢您的帮助和非常及时的回复。感谢 John 关于 --extra-lib-dir 的 cmets,我发现了问题所在。

标签: haskell homebrew haskell-platform libiconv


【解决方案1】:

感谢 Daniel 和 John 的投入,我找到了解决自己问题的方法。

就我而言,foobar: mkTextEncoding: failed (Unknown error: 0) FAIL: 1 是由与 gd 库的不可靠链接引起的。

可以通过检查二进制文件使用的库来发现问题。

$ otool dist/build/foobar/foobar -L
foobar:
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    libgd.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/lib/libpng12.0.dylib (compatibility version 47.0.0, current version 47.0.0)
    /usr/local/lib/libjpeg.8.dylib (compatibility version 12.0.0, current version 12.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
    /usr/local/lib/libfontconfig.1.dylib (compatibility version 6.0.0, current version 6.4.0)
    /usr/local/lib/libfreetype.6.dylib (compatibility version 15.0.0, current version 15.0.0)
    /usr/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

奇怪的线当然向我们展示了罪魁祸首:

    libgd.dylib (compatibility version 0.0.0, current version 0.0.0)

版本和位置看起来很奇怪。删除对gd 的依赖使我的程序再次运行。但是,我没有设法让libgd 在我的 Mac 上工作。这个问题超出了这个问题的范围。

【讨论】:

    猜你喜欢
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多