ruby - 我无法在 Windows 上安装 rmagick gem

标签 ruby windows ruby-on-rails-3 imagemagick rmagick

我使用了 ruby​​ 1.9.2 和 rails 3.0.3。我正在尝试安装 rmagick gem,但是当我运行 bundle install 时,我收到一条错误消息:

Installing rmagick (2.12.1) with native extensions c:/Ruby192/lib/ruby/site_ruby
/1.9.1/rubygems/installer.rb:529:in `rescue in block in build_extensions': ERROR
: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

       c:/Ruby192/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... 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=c:/Ruby192/bin/ruby
c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postp
one'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
       from c:/Ruby192/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
       from extconf.rb:171:in `<main>'


Gem files will remain installed in c:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2
.12.1 for inspection.
Results logged to c:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.12.1/ext/RMagick
/gem_make.out
       from c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:507:in `b
lock in build_extensions'
       from c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `e
ach'
       from c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `b
uild_extensions'
       from c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:156:in `i
nstall'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/sour
ce.rb:96:in `install'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/inst
aller.rb:55:in `block in run'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec
_set.rb:12:in `block in each'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec
_set.rb:12:in `each'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec
_set.rb:12:in `each'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/inst
aller.rb:44:in `run'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/inst
aller.rb:8:in `install'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/cli.
rb:226:in `install'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vend
or/thor/task.rb:22:in `run'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vend
or/thor/invocation.rb:118:in `invoke_task'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vend
or/thor.rb:246:in `dispatch'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vend
or/thor/base.rb:389:in `start'
       from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/bin/bundle:13:in
`<top (required)>'
       from c:/Ruby192/bin/bundle:19:in `load'
       from c:/Ruby192/bin/bundle:19:in `<main>'

我从 http://rubyinstaller.org/downloads/ 安装了 ruby带有开发工具包和最新版本的 ImageMagick。我尝试设置 rmagick 配置(lib 和 include 目录)但我仍然遇到相同的错误

有什么帮助吗?有解决问题的想法吗?

最佳答案

先决条件:
ruby > 1.8.6
DevKit(任何版本)
没有其他 ImageMagick 安装或 PATH 条目

第 1 步: 安装 ImageMagick:

下载 ImageMagick: http://imagemagick.spd.co.il/binaries/ImageMagick-6.8.0-3-Q16-windows-dll.exe

安装ImageMagick:
*重要提示:安装路径不能包含任何空格。
理想情况下选择“C:\ImageMagick”

请确保选择以下选项:

Add application directory to your path system
Install development headers and libraries for C and C++

第 2 步: 安装 rmagick:

使用以下命令安装 rmagick gem:

gem install rmagick --platform=ruby -- --with-opt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include

通过-

http://shoobm.wordpress.com/2013/01/03/installing-rmagick-gem-on-windows-7/

关于ruby - 我无法在 Windows 上安装 rmagick gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4873276/

相关文章:

ruby - 为什么我在调用 Shoes #'visit' 时会丢失我的实例变量?

windows - Windows环境变量嵌套的限制?

ruby-on-rails-3 - Heroku 的机架迷你分析器?

ruby-on-rails - Rails 3 - 与自身具有一对一关系的模型 - 我是否需要belongs_to

ruby-on-rails-3 - 使用 RSpec 2 和 Rails3 测试嵌套命名空间 Controller

ruby - 如何在 Ruby 中干净地 "reattach"一个分离的方法?

ruby - 无法在 ruby​​ 中修改自身为整数

ruby-on-rails - ruby 2.1.2 中 "#$e"的含义是什么

c++ - 在 linux 上运行 cygwin 编译的 c++ 程序

windows - Windows 上的 glfwSwapBuffers() 和垂直刷新