在Mountain Lion上安装ImageMagick和rmagick的问题

时间:2012-07-26 19:43:08

标签: imagemagick rmagick osx-mountain-lion

我正面临在山狮中安装rmagick的问题。我已经安装了Xcode 4.4和开发人员工具。仍然面临这个问题。

    Installing rmagick (2.13.1) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
    /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

            /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/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
        --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/mohit/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
    /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/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.
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
        from extconf.rb:193:in `<main>'


    Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1 for inspection.
    Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `block in build_extensions'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `each'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `build_extensions'
        from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `install'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:90:in `block in install'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:82:in `preserve_paths'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:89:in `install'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:73:in `block in install_gem_from_spec'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:97:in `with_build_args'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:72:in `install_gem_from_spec'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:56:in `block in run'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:55:in `run'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:12:in `install'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/cli.rb:220:in `install'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/task.rb:22:in `run'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor.rb:263:in `dispatch'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/base.rb:386:in `start'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/bin/bundle:13:in `<top (required)>'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `load'
        from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `<main>'

11 个答案:

答案 0 :(得分:20)

我今天早上刚刚更新到Mountain Lion并且遇到了rmagick麻烦。我曾经在过去的某个时刻通过自制软件安装了ImageMagick,所以在通过xcode的首选项窗口安装新的命令行工具后,这对我有用。

brew update
brew uninstall ImageMagick
brew install ImageMagick
gem uninstall rmagick
gem install rmagick

我没有像上面提到的帖子那样使用gcc来获得时髦。

答案 1 :(得分:14)

我终于解决了这个问题:

$ cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
$ ln -s libMagick++-Q16.7.dylib   libMagick++.dylib
$ ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib

解决方案来自https://coderwall.com/p/wnomjg

答案 2 :(得分:13)

我得到了相同的

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

按照https://gist.github.com/1860511

中的说法做到了

答案 3 :(得分:3)

因此,在将我的mac pro更新为Mountain Lion之后,我的ruby环境开始一个接一个地用不同的错误尖叫。 经过1-2个小时的试用 - 错误和谷歌搜索,这是我在rails环境中修复ruby的方法。

首先我得到了ruby env错误。它没有检测到git命令,而Bundler正在尖叫 我跑foreman start

时出错

Step1 Update XCode。获取最新的Xcode 4.6 Mountain Lion没有预先安装ruby标头,因此您需要从XCode手动执行此操作。转到Xcode首选项/下载。

Install Command Line Tools

第2步: Install XQuartz

再次退出并登录。 (您可能不需要这个,因为imagemagick公式已更新

第3步:现在,您的ruby env将开始谈论Imagemagick错误 这样做:

brew update

brew uninstall imagemagick

brew install --fresh imagemagick

gem uninstall rmagick 2.13.2

gem install rmagick

尝试完最后一个,现在它会给你这样的原生扩展错误

Installing rmagick (2.13.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb 
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/gcc-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby


Gem files will remain installed in /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-      2.13.1 for inspection.
Results logged to /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
An error occured while installing rmagick (2.13.1), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.1'` succeeds before bundling.

第4步: sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

这应该可以解决Mountain Lion在升级后给你的所有问题。

只需运行bundle

答案 4 :(得分:1)

尝试更改路径,使/ usr / local / bin在/ usr / bin之前插入。我找到了这个正在运行的酿造医生,它让我完成了imagemagick的编译。

答案 5 :(得分:1)

以下是我几次尝试后如何获得RMagick工作的快速摘要。我觉得以下是获得它的最佳方式,而不必去下载源代码压缩包和编译的麻烦 - 留给专家

  • 您需要为gcc / g ++等安装Xcode和命令行工具。命令行工具不会自动安装Xcode,转到首选项并安装
  • 下一步安装Macport
  • 同时安装Homebrew
  • 确保安装了X11服务器 - 如果没有安装 - sudo port install -v xorg-server。我使用-v选项,因为它是一个长安装 你可能想知道它是做某事还是只是挂着
  • 安装pkgconfig - sudo brew install pkgconfig
  • 现在是时候安装ImageMacick了 - sudo port install -v ImageMagick 不要使用brew来安装ImageMagick - 它不能正确安装所有依赖项和委托。
  • 安装ImageMagick后 - 设置DISPLAY env变量 - export DISPLAY=:0.0 - 最好还是将其放在.profile
  • 现在测试您的ImageMagick安装
  • 启动X11服务器(安装X11服务器后,它将在那里 你的应用程序列表)
  • 从命令行运行 - $convert logo: logo.gif; identify logo.gif; display logo.gif - 它会弹出一个显示logo.gif
  • 的窗口
  • 还可以从命令行运行命令 - $convert -list configure | grep -i delegates。它应输出以下
    DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma png tiff x11 xml zlib

  • 现在你应该设置为运行 sudo gem install RMagick

成功安装RMagick后 - 检查它的安装位置,转到示例目录并运行某些程序。

答案 6 :(得分:1)

没有解决方案适合我,最终我运行brew doctor并发现我需要将imagemagick与brew link --overwrite imagemagick

相关联

答案 7 :(得分:1)

我有类似的问题,但在El Captain。更好地解释here。 安装xcode命令行工具后修复:

xcode-select --install

答案 8 :(得分:0)

您需要安装XCode 4.4,命令行工具等。请在此处查看完整列表: http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html

答案 9 :(得分:0)

我发现我的解决方案是上面列出的步骤的组合,位于http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.htmlhttp://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion,尽管我不必执行任何一个帖子中列出的所有步骤。但我确实需要从XCode安装命令行工具,我在前几次错过了这个细节。我还必须使用自制软件安装gcc-4.2,并在我的bin目录中创建一个sym链接到该安装。

我可能会对不同编译器的情况感到困惑,但我会谨慎地将/ usr / bin / gcc链接到/usr/bin/gcc-4.2(这可能是gcc-的链接4.2由自制软件安装)。在我意识到我需要安装命令行工具之前,我曾尝试制作sym链接,然后我开始看到其他gem构建失败。安装命令行工具修复了这些问题 - 我相信xcode命令行工具使它成为llvm-gcc-4.2的sym链接。

答案 10 :(得分:0)

我刚刚安装了rmagick 2.13.2,这个问题就消失了。

相关问题