gpt4 book ai didi

haskell - 运行 Haskell 代码时的架构 x86_64,Haskell OSX iconv

转载 作者:行者123 更新时间:2023-12-04 03:13:05 26 4
gpt4 key购买 nike

当我在我的计算机上编译一个工作的 Haskell 代码时,它抛出了 x86_64 架构的这个错误。它在我 friend 的具有相同架构的计算机上运行良好。

  $ ghc --make BoardMain.hs
Linking BoardMain ...
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_hs_iconv in libHSbase-4.9.1.0.a(iconv.o)
(maybe you meant: _hs_iconv, _base_GHCziIOziEncodingziIconv_iconvEncoding5_closure , _base_GHCziIOziEncodingziIconv_iconvEncodingzuloc_info , _base_GHCziIOziEncodingziIconv_iconvEncoding9_info , _hs_iconv_open , _base_GHCziIOziEncodingziIconv_iconvEncoding10_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding11_info , _base_GHCziIOziEncodingziIconv_iconvEncoding7_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding8_info , _base_GHCziIOziEncodingziIconv_iconvEncoding11_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding8_closure , _base_GHCziIOziEncodingziIconv_iconvEncodingzuloc_closure , _hs_iconv_close , _base_GHCziIOziEncodingziIconv_iconvEncoding4_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding10_info , _base_GHCziIOziEncodingziIconv_iconvEncoding3_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding9_closure , _base_GHCziIOziEncodingziIconv_iconvEncoding2_closure , _base_GHCziIOziEncodingziIconv_iconvEncodingzuloc1_info , _base_GHCziIOziEncodingziIconv_iconvEncoding7_info , _base_GHCziIOziEncodingziIconv_iconvEncoding2_info , _base_GHCziIOziEncodingziIconv_iconvEncoding4_info , _base_GHCziIOziEncodingziIconv_iconvEncodingzuloc1_closure )
"_iconv_close", referenced from:
_hs_iconv_close in libHSbase-4.9.1.0.a(iconv.o)
(maybe you meant: _hs_iconv_close)
"_iconv_open", referenced from:
_hs_iconv_open in libHSbase-4.9.1.0.a(iconv.o)
(maybe you meant: _hs_iconv_open)
"_locale_charset", referenced from:
_localeEncoding in libHSbase-4.9.1.0.a(PrelIOUtils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

最佳答案

错误不是由于架构造成的。错误是因为另一个可能与 MacPorts 一起安装的 libiconv 位于

/opt/local/lib as /opt/local/lib/libiconv.*



在编译代码时,它指的是 Macports libiconv,它与 OS X libiconv 有某种不同。我们需要机器使用 OS X libiconv 以确保它使用 OS X libconv

/usr/lib as /usr/lib/libiconv.*



我们需要将额外的库方向命令传递给 cabal 或 ghc .. 同时通过添加 -L/usr/lib 即,
ghc -L/usr/lib --make file.hs
cabal exec -- ghc -L/usr/lib --make BoardMain.hs

您甚至可以尝试添加
额外的库目录:
-/usr/lib
到我们的 stack.yaml。引用 this有关这方面的更多信息。

或者通过在/opt/local/lib 停用 libconv 如果您确定它们不会破坏其他文件中的某些链接。

关于haskell - 运行 Haskell 代码时的架构 x86_64,Haskell OSX iconv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43359289/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com