Windows 8.1にGHCの環境を構築しているのですが、
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
というエラーが出るようになってしまいました。
エラー・メッセージで検索したサイトのひとつに次のサイトがありました。
GHCi runtime linker: fatal error: I found a duplicate definition for symbol 出現時のメモを見ますと異なるバージョンのパッケージが二つ入っているということです。
Key型には hash を求めるインスタンスを定義してあります。
data Key = Key Int String deriving (Eq,Show) instance Hashable Key where hashWithSalt s (Key a b) = s `hashWithSalt` a `hashWithSalt` b
GHCiでKey型を表示しようとするとと、hashable-1.1.2.5を読み込んで、さらにhashable-1.2.1.0を読み込んだ時点でエラーになっています。
GHCi runtime linker: *Main> Key 1"hello" Loading package array-0.4.0.1 ... linking ... done. Loading package deepseq-1.3.0.1 ... linking ... done. Loading package primitive-0.5.0.1 ... linking ... done. Loading package vector-0.10.0.1 ... linking ... done. Loading package bytestring-0.10.0.2 ... linking ... done. Loading package text-0.11.3.1 ... linking ... done. Loading package hashable-1.1.2.5 ... linking ... done. Loading package hashable-1.2.1.0 ... GHCi runtime linker: fatal error: I found a duplicate definition for symbol _hashable_fnv_hash whilst processing object file C:\Users\sirocco\AppData\Roaming\cabal\i386-windows-ghc-7.6.3\hashable-1.2.1.0\libHShashable-1.2.1.0.a This could be caused by: * Loading two different object files which export the same symbol * Specifying the same object file twice on the GHCi command line * An incorrect `package.conf' entry, causing some object to be loaded twice. GHCi cannot safely continue in this situation. Exiting now. Sorry.
この問題を解決するために、古い hashable-1.1.2.5 をunregisterします。
$ ghc-pkg unregister hashable-1.1.2.5 ghc-pkg.exe: unregistering hashable-1.1.2.5 would break the following packages: unordered-containers-0.2.3.0 haskell-platform-2013.2.0.0 case-insensitive-1.0.0.1 hashtables-1.1.2.1 HStringTemplate-0.7.1 void-0.6.1 semigroups-0.12.1 (use --force to override)
(use --force to override) と言われるので "--force" をつけてやりなおし。
$ ghc-pkg --force unregister hashable-1.1.2.5 unregistering hashable-1.1.2.5 would break the following packages: unordered- containers-0.2.3.0 haskell-platform-2013.2.0.0 case-insensitive-1.0.0.1 hashtables- 1.1.2.1 HStringTemplate-0.7.1 void-0.6.1 semigroups-0.12.1 (ignoring)
Data.HashTable.IO が読めないエラーが発生してしまいます。
ghc-pkg list でみると hashtables-1.1.2.1がunregisterになってしまったようです。
C:\Users\sirocco\AppData\Roaming\ghc\i386-mingw32-7.6.3\package.conf.d: Cabal-1.18.1.2 {HStringTemplate-0.7.1} blaze-builder-0.3.3.2 containers-0.4.2.1 datetime-0.2.1 hashable-1.2.1.0 {hashtables-1.1.2.1} nats-0.1.2 safe-0.3.3 {semigroups-0.12.1} strict-0.3.2 utf8-string-0.3.7 {void-0.6.1} wx-0.13.2.3 wxcore-0.13.2.3 wxdirect-0.13.1.3 wxdirect-0.90.0.1
hashable-1.2.1.0をunregisterして再度 hashtables をインストールするとOKでした。
$ ghc-pkg unregister hashable-1.2.1.0
Main> Key 1"abc" Loading package array-0.4.0.1 ... linking ... done. Loading package deepseq-1.3.0.1 ... linking ... done. Loading package primitive-0.5.0.1 ... linking ... done. Loading package vector-0.10.0.1 ... linking ... done. Loading package bytestring-0.10.0.2 ... linking ... done. Loading package text-0.11.3.1 ... linking ... done. Loading package hashable-1.2.1.0 ... linking ... done. Loading package hashtables-1.1.2.1 ... linking ... done. Key 1 "abc" Main> hash (Key 1"abc") -1314789693
参考