安装rmagick时出错:错误:无法构建gem原生扩展

时间:2012-04-05 12:10:01

标签: ruby rmagick

我正在尝试使用以下命令安装RmMagic:

gem install rmagick -v=2.12.2

运行此命令后,我收到一些错误:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.


        D:/ruby/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** 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=D:/ruby/bin/ruby


Gem files will remain installed in D:/ruby/lib/ruby/gems/1.8/gems/rmagick-2
.12.2 for inspection.
Results logged to D:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.12.2/ext/RMagick
/gem_make.out

请在这方面帮助我。提前谢谢。

2 个答案:

答案 0 :(得分:3)

我遇到了与rmagick相同的问题来解决这个添加系统环境变量

CLASSPATH .;C:\ImageMagick-6.5.6-Q8\include

lib C:\ImageMagick-6.5.6-Q8\lib

然后做

gem install rmagick  --platform=ruby -- --with-opt-lib=C:\ImageMagick-6.5.6-Q8\lib --with-opt-include=C:\ImageMagick-6.5.6-Q8\include

答案 1 :(得分:0)

这是多么痛苦......我绝对需要按照Mukesh的建议同时执行系统环境变量和命令的特定语法

澄清两个步骤:(对于像我这样的其他新手)

点击“计算机”的上下文菜单中的属性,点击“高级系统设置”, 单击“环境变量”,单击“系统变量”下的“新建”,

使用CLASSPATH作为变量名称和值使用:

.;C:\ImageMagick-6.9.0-Q16\include;lib C:\ImageMagick-6.9.0-Q16\lib

然后使用Ruby终端以管理员身份运行命令提示符并执行:

gem install rmagick -v '2.13.4' -- --with-opt-lib=C:\ImageMagick-6.9.0-Q16\lib --with-opt-include=C:\ImageMagick-6.9.0-Q16\include

(***确保在必要时更新Variable和gem命令中的版本号)

相关问题