为什么我在安装rmagick时遇到问题

时间:2011-03-24 05:43:24

标签: ruby-on-rails ruby rmagick

在Ruby 1.8.7和rails 2.3.5上,我得到:

gem install rmagick

ERROR:  Error installing rmagick:

ERROR: Failed to build gem native extension.


    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
    mkmf.rb can't find header files for ruby at       
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1 for inspection.

Results logged to /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

Building native extensions.  This could take a while...

Cynicalgrinch:levelous pawel$ gem install rmagick

Building native extensions.  This could take a while...

ERROR:  Error installing rmagick:

    ERROR: Failed to build gem native extension.


        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1 for inspection.

Results logged to /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out


Gem_make.out says this:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

3 个答案:

答案 0 :(得分:29)

在Ubuntu / Debian上你需要安装:

sudo apt-get install libmagickwand-dev

在RedHat / Fedora / CentOS上:

yum install ImageMagick-devel

答案 1 :(得分:12)

要使用gem系统安装rmagick,您必须在系统上安装“imagemagick”。以下错误行表示rmagick无法构建,因为系统上不存在本机扩展(imagemagick)。

ERROR: Failed to build gem native extension.

在OSX上,您可以使用brew(我认为最好的方式)来安装imagemagick。一旦安装了brew:

brew install imagemagick
gem install rmagick

On Mountain Lion(OSX),之后:

brew install imagemagick

在能够安装rmagick gem之前,可能需要手动重新创建一些符号链接。

> brew link -f jpeg
> brew link -f libpng
> brew link -f freetype
> brew link -f imagemagick

答案 2 :(得分:0)

在fedora上确保安装了ImageMagick-devel