Mac Rmagick 无法安装 Xcode 4.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7961091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:17:44  来源:igfitidea点击:

Mac Rmagick won't install with Xcode 4.2

rubyxcodegccimagemagickrmagick

提问by Danny Hiemstra

I just got a new macbook pro and trying to setup my dev environment. I downloaded xcode 4.2 from the app store and installed it, after this i installed homebrew and RVM. ImageMagick, readline, ruby 1.9.3-head all installed perfectly until i ran bundle update which tried to install rmagick.

我刚买了一台新的 macbook pro 并尝试设置我的开发环境。我从应用商店下载了 xcode 4.2 并安装了它,之后我安装了自制软件和 RVM。ImageMagick、readline、ruby 1.9.3-head 全部安装完美,直到我运行 bundle update 试图安装 rmagick。

After a long long time investigating i come down to the conclusion that it can't find libgomp.

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

The output is from gem install rmagickis:

输出来自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.

Here is my mkmf.log file:

这是我的 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 */

Now i assumed here that something was wrong with xcode i tried several things:

现在我在这里假设 xcode 有问题我尝试了几件事:

  • Reinstall xcode
  • Remove imagemagick and reinstalled it including other libraries like jpg, libpng etc
  • Installed older version of imagemagick
  • Removed .rvm and reinstalled a fresh copy of ruby
  • 重新安装 xcode
  • 删除 imagemagick 并重新安装它,包括其他库,如 jpg、libpng 等
  • 安装旧版本的 imagemagick
  • 删除 .rvm 并重新安装 ruby​​ 的新副本

I have no clue what's left for me to try, could anyone help to push me in the good direction?

我不知道还有什么可以尝试的,有人可以帮助我朝着好的方向发展吗?

采纳答案by Danny Hiemstra

I tried to download and install 4.1 for lion and this didn't even install (without a proper error message). Now a colleague gave me this great link to GCC for Mac which worked like a charm: https://github.com/kennethreitz/osx-gcc-installer

我尝试为 Lion 下载并安装 4.1 并且这甚至没有安装(没有正确的错误消息)。现在,一位同事给了我这个很棒的 GCC for Mac 链接,它就像一个魅力:https: //github.com/kennethreitz/osx-gcc-installer

Don't forget to download the v2 if you run on > 10.7.0

如果您在 > 10.7.0 上运行,请不要忘记下载 v2

回答by Aurélien Bottazini

I tried your solution (full of hope) but It did not work for me unfortunately. Finally I managed to make it work by reinstalling imagemagick without openmp support (this is the library responsible for lgomp)

我尝试了您的解决方案(充满希望),但不幸的是它对我不起作用。最后我设法通过在没有 openmp 支持的情况下重新安装 imagemagick 使其工作(这是负责 lgomp 的库)

using Homebrew:

使用自制软件:

brew install imagemagick --disable-openmp

then rmagick installed without any problems.

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

回答by RubyFanatic

For people who want source installation, you can download the source code repository and issue this command in the imagemagick source code directory.

想要源码安装的可以下载源码仓库,在imagemagick源码目录下发出这个命令。

./configure --disable-openmp

./configure --disable-openmp

It will work similar to the brew version above but with source code compilation instead.

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

回答by toppsdown

I ran into this problem using Macports but there are no guides so I'll add one here:

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

  1. uninstall ImageMagick: 'sudo port uninstall ImageMagick' // and any dependents
  2. download Portfile-ImageMagick.diff from here
  3. Follow guide(transcribed below): 'cd $(port dir ImageMagick)' 'patch -p0 < (downloaded patch file)'
  4. 'sudo port install ImageMagick +no_openmp'
  1. 卸载 ImageMagick: 'sudo port uninstall ImageMagick' // 和任何依赖
  2. 这里下载 Portfile-ImageMagick.diff
  3. 按照指南(转录如下): 'cd $(port dir ImageMagick)' 'patch -p0 < (下载的补丁文件)'
  4. 'sudo 端口安装 ImageMagick +no_openmp'