在 OS X Yosemite 10.10 (14A389) 上安装 QuickCheck for GHC 7.8.3 时出现 Clang 错误

Posted

技术标签:

【中文标题】在 OS X Yosemite 10.10 (14A389) 上安装 QuickCheck for GHC 7.8.3 时出现 Clang 错误【英文标题】:Clang error while installing QuickCheck for GHC 7.8.3 on OS X Yosemite 10.10 (14A389) 【发布时间】:2014-10-24 15:32:10 【问题描述】:

在装有 Xcode 6.1 (6A1052d) 的 Mac Pro 2013 上运行的 OS X Yosemite 10.10 (14A389) 系统上安装 Haskell GHC 7.8.3 的 QuickCheck 时,我遇到了以下 clang 错误:

   $ cabal install QuickCheck
Resolving dependencies...
Configuring primitive-0.5.4.0...
Building primitive-0.5.4.0...
Preprocessing library primitive-0.5.4.0...
[ 1 of 10] Compiling Data.Primitive.Internal.Compat ( Data/Primitive/Internal/Compat.hs, dist/build/Data/Primitive/Internal/Compat.o )
[ 2 of 10] Compiling Data.Primitive.MachDeps ( Data/Primitive/MachDeps.hs, dist/build/Data/Primitive/MachDeps.o )
[ 3 of 10] Compiling Data.Primitive.Internal.Operations ( Data/Primitive/Internal/Operations.hs, dist/build/Data/Primitive/Internal/Operations.o )
[ 4 of 10] Compiling Control.Monad.Primitive ( Control/Monad/Primitive.hs, dist/build/Control/Monad/Primitive.o )
[ 5 of 10] Compiling Data.Primitive.Types ( Data/Primitive/Types.hs, dist/build/Data/Primitive/Types.o )
[ 6 of 10] Compiling Data.Primitive.Array ( Data/Primitive/Array.hs, dist/build/Data/Primitive/Array.o )

Data/Primitive/Array.hs:32:1: Warning:
    The import of ‘Control.Monad.ST’ is redundant
      except perhaps to import instances from ‘Control.Monad.ST’
    To import instances alone, use: import Control.Monad.ST()
[ 7 of 10] Compiling Data.Primitive.ByteArray ( Data/Primitive/ByteArray.hs, dist/build/Data/Primitive/ByteArray.o )
[ 8 of 10] Compiling Data.Primitive.Addr ( Data/Primitive/Addr.hs, dist/build/Data/Primitive/Addr.o )
[ 9 of 10] Compiling Data.Primitive   ( Data/Primitive.hs, dist/build/Data/Primitive.o )
[10 of 10] Compiling Data.Primitive.MutVar ( Data/Primitive/MutVar.hs, dist/build/Data/Primitive/MutVar.o )
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Failed to install primitive-0.5.4.0
Configuring random-1.1...
Building random-1.1...
Preprocessing library random-1.1...
[1 of 1] Compiling System.Random    ( System/Random.hs, dist/build/System/Random.o )
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Failed to install random-1.1
cabal: Error: some packages failed to install:
QuickCheck-2.7.6 depends on random-1.1 which failed to install.
primitive-0.5.4.0 failed during the building phase. The exception was:
ExitFailure 1
random-1.1 failed during the building phase. The exception was:
ExitFailure 1
tf-random-0.5 depends on random-1.1 which failed to install.

动态库gmp好像不见了。有人找到解决这个问题的方法了吗?

【问题讨论】:

这里也一样。昨天刚拿到优胜美地。我什么时候才能学会不及早采用 OS X 升级。 试试:xcode-select --install 当然,就是这样。谢谢@MichaelFox,我完全忘记了命令行工具的安装。请提交作为您的答案。 【参考方案1】:

正如@MichealFox 在他的评论中所说,安装命令行工具可以解决这个问题。

xcode-select --install

它还解决了许多其他 cabal 软件包的问题,​​具体取决于 gmp/lgmp 库。

【讨论】:

【参考方案2】:

我遇到了同样的问题(在我的例子中,我在 Centos 7 机器上编译 pandoc)。

安装了gmp RPM,但未安装gmp-devel RPM(包含头文件、可链接库等)。这修复了它:

yum install gmp-devel

【讨论】:

以上是关于在 OS X Yosemite 10.10 (14A389) 上安装 QuickCheck for GHC 7.8.3 时出现 Clang 错误的主要内容,如果未能解决你的问题,请参考以下文章

sh 翻译:“OS X 10.10 Yosemite本地开发环境,Apache,PHP和MySQL与Homebrew”14。安装,配置DNSMasq

Mac OS X Yosemite 10.10 配置 Apache+PHP 教程注意事项

sh OS X 10.10 Yosemite升级检查

在 Mac OS X Yosemite 10.10 上使用 Mamp Pro 进行 Mcrypt

安装 Mac OS X Yosemite (Mac OS 10.10) 后 Eclipse 无法启动

Axure7.0在OS X Yosemite(10.10)中不能用的问题