2017-04-12 68 views
0

當我在我的計算機上編譯工作的Haskell代碼時,它拋出了體系結構x86_64的這個錯誤。我的朋友的計算機工作正常,它的架構相同。體系結構x86_64運行Haskell代碼時,Haskell OSX iconv

$ 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) 
+2

這個問題根本與x86_64沒有關係,而是(C)庫版本控制問題。如果你是Google的「Haskell OSX iconv」,你會得到一些有趣的點擊。也許從這個搜索中嘗試一些事情;希望他們中的一個能夠工作。 (如果是這樣的話,你應該在這裏寫一個答案,告訴你哪種方法適用於你!) –

+0

編譯時,如果我只是將「-L/usr/lib」附加到ghc中,它就是在沒有這些iconv錯誤的情況下編譯的。即$ ghc -L/usr/lib --make file.hs @DanielWagner – Aerron

回答

0

錯誤不是由於體系結構。該錯誤是由於可能與安裝MacPorts的另一libiconv的是

的/ opt/local/lib目錄作爲/opt/local/lib/libiconv.*

雖然編譯代碼,它指的是與Mac OS X libiconv不同的Macports libiconv。我們需要對計算機使用OS X libiconv的這樣,以確保它使用的OS X libconv這是

/usr/lib目錄作爲/usr/lib/libiconv.*

我們需要額外的庫方向指令傳遞給小集團或GHC ..同時通過添加-L/usr/lib目錄即

ghc -L/usr/lib --make file.hs 
cabal exec -- ghc -L/usr/lib --make BoardMain.hs 

你甚至可以嘗試添加 額外LIB-DIR編譯: - 在/ usr/lib 到我們的stack.yaml。請參閱this瞭解更多信息。

或者通過取消激活libconv /opt/local/lib如果您確定它們不打算在某些其他文件中斷開某個鏈接。