Mac上安装Xcode 4.2后,Rmagick无法安装。

20

我刚拿到一台新的Macbook Pro并尝试设置我的开发环境。我从应用商店下载了Xcode 4.2并安装了它,然后我安装了Homebrew和RVM。ImageMagick、readline和ruby 1.9.3-head都安装成功了,直到我运行bundle update尝试安装rmagick。

经过长时间的调查,我得出结论它无法找到libgomp。

gem install rmagick的输出如下:

$ gem install rmagick
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

        /Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/bin/ruby
/Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

这是我的 mkmf.log 文件:

"clang -o conftest -I/Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/include/ruby-1.9.1/x86_64-darwin11.2.0 -I/Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/include/ruby-1.9.1/ruby/backward -I/Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/include/ruby-1.9.1 -I.  -I/usr/local/Cellar/imagemagick/6.7.1-1/include/ImageMagick  -I/usr/local/Cellar/imagemagick/6.7.1-1/include/ImageMagick -fopenmp conftest.c  -L. -L/Users/dhiemstra/.rvm/rubies/ruby-1.9.3-head/lib  -L/usr/local/Cellar/imagemagick/6.7.1-1/lib -L/usr/X11/lib    -L/usr/local/Cellar/imagemagick/6.7.1-1/lib -lMagickCore -llcms -ltiff -lfreetype -ljpeg -L/usr/X11/lib -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lpthread -lltdl  -lruby.1.9.1  -lpthread -ldl -lobjc "
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

我认为 Xcode 出了些问题,尝试了以下几个步骤:

  • 重新安装 Xcode
  • 移除并重新安装 ImageMagick,并包括其他库文件如 jpg、libpng 等
  • 安装旧版本的 ImageMagick
  • 移除 .rvm 并重新安装 Ruby

我不知道还有什么方法可尝试,是否有人可以指点一下方向?

4个回答

67

我满怀希望地尝试了你的解决方案,但不幸的是它对我没有起作用。最终,我通过重新安装不带 openmp 支持的 imagemagick(这个库负责 lgomp)来使其工作。

使用 Homebrew:

brew install imagemagick --disable-openmp

然后rmagick安装没有任何问题。


3
你是一个救星,我已经将这个信息添加到了 GitHub 上的开放式 rmagick 问题提交中 https://github.com/rmagick/rmagick/issues/36。 - David Burrows
这在某种程度上可以工作,但我不得不访问https://dev59.com/s2w15IYBdhLWcg3weLoF才能真正让它工作。 - brad
只想指出这里的问题是Ruby 1.9.3,而不是xcode 4.2。使用来自brew的Vanilla imagemagick与xcode 4.2和ruby <= 1.9.2完全正常。 - bloudermilk

1
对于想要源代码安装的用户,您可以下载源代码仓库并在imagemagick源代码目录中执行以下命令:

./configure --disable-openmp

它将类似于上面的brew版本,但使用源代码编译。

1
我试图下载和安装Lion的4.1版本,但它甚至没有正确的错误信息就无法安装。 现在我的同事给了我这个非常好的Mac GCC链接,它非常好用: https://github.com/kennethreitz/osx-gcc-installer 别忘了如果你使用的是>10.7.0版本,要下载v2。

0

我在使用Macports时遇到了这个问题,但是没有指南,所以我会在这里添加一个:

  1. 卸载ImageMagick:'sudo port uninstall ImageMagick' //和任何依赖项
  2. here下载Portfile-ImageMagick.diff
  3. 按照guide(以下是转录): 'cd $(port dir ImageMagick)' 'patch -p0 <(下载的补丁文件)'
  4. 'sudo port install ImageMagick +no_openmp'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接