在Windows上为Ruby on Rails安装RMagick时出错

时间:2014-11-21 11:59:05

标签: ruby-on-rails windows bundler redmine rmagick

我正在尝试在Windows 7上安装Ruby on Rails和Redmine on Xampp。我在此链接后成功安装了ImageMagick和RMagick:

http://rails.webintellix.com/2010/01/04/how-to-install-rmagick-imagemagick-on-windows/

但是当我运行bundle install时,我收到以下错误:

C:\xampp\htdocs\dev-ruby\redmine>bundle install
DL is deprecated, please use Fiddle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using multi_json 1.10.1
Using activesupport 3.2.19
Using builder 3.0.4
Using activemodel 3.2.19
Using erubis 2.7.0
Using journey 1.0.4
Using rack 1.4.5
Using rack-cache 1.2
Using rack-test 0.6.2
Using hike 1.2.3
Using tilt 1.4.1
Using sprockets 2.2.3
Using actionpack 3.2.19
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 3.2.19
Using arel 3.0.3
Using tzinfo 0.3.42
Using activerecord 3.2.19
Using activeresource 3.2.19
Using bundler 1.7.6
Using mini_portile 0.6.1
Using nokogiri 1.6.4.1
Using xpath 2.0.0
Using capybara 2.1.0
Using ffi 1.9.6
Using childprocess 0.5.5
Using coderay 1.1.0
Using rack-ssl 1.3.4
Using json 1.8.1
Using rdoc 3.12.2
Using thor 0.19.1
Using railties 3.2.19
Using jquery-rails 3.1.2
Using metaclass 0.0.4
Using mocha 1.0.0
Using mysql 2.8.1
Using net-ldap 0.3.1
Using ruby-openid 2.3.0
Using rack-openid 1.4.2
Using rails 3.2.19
Using rbpdf 1.18.2
Using redcarpet 2.3.0
Using request_store 1.0.5

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

    C:/RailsInstaller/Ruby2.0.0/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:/RailsInstaller/Ruby2.0.0/bin/ruby
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler
 failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:562:in `try_cpp'

        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:1041:in `block i
n have_header'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:892:in `block in
 checking_for'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:337:in `block (2
 levels) in postpone'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:337:in `block in
 postpone'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:333:in `postpone
'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:891:in `checking
_for'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:1040:in `have_he
ader'
        from extconf.rb:186:in `<main>'


Gem files will remain installed in C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0
.0/gems/rmagick-2.13.3 for inspection.
Results logged to C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rmagick-2
.13.3/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.3), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.13.3'` succeeds before bundling.

所以我尝试使用这个命令安装rmagick 2.13.3:

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

但它也给出了这个错误:

C:\Users\user1>gem install rmagick --version=2.13.3 --platform=ruby -- --with-op
t-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-lib=c:/ImageMagick/lib --with-opt-i
nclude=c:/ImageMagick/include'
This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb --with-opt-lib=c:/ImageM
agick/lib --with-opt-include=c:/ImageMagick/include
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=${opt-dir}/include
        --with-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/RailsInstaller/Ruby2.0.0/bin/ruby
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler
 failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:562:in `try_cpp'

        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:1041:in `block i
n have_header'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:892:in `block in
 checking_for'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:337:in `block (2
 levels) in postpone'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:337:in `block in
 postpone'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:333:in `postpone
'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:891:in `checking
_for'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/mkmf.rb:1040:in `have_he
ader'
        from extconf.rb:186:in `<main>'


Gem files will remain installed in C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0
.0/gems/rmagick-2.13.3 for inspection.
Results logged to C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rmagick-2
.13.3/ext/RMagick/gem_make.out

这是mkmf.log文件:

checking for Ruby version >= 1.8.5... -------------------- yes

--------------------

"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/backward -IC:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/RailsInstaller/Ruby2.0.0/lib -L.    -lCORE_RL_magick_ -lX11  -lmsvcrt-ruby200  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
In file included from C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby.h:33:0,
                 from conftest.c:1:
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:125:14: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby.h:33:0,
                 from conftest.c:1:
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_float_value':
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:826:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_num2char_inline':
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1214:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1214:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1214:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1215:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1215:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1215:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_class_of':
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1514:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h: In function 'rb_type':
C:/RailsInstaller/Ruby2.0.0/include/ruby-2.0.0/ruby/ruby.h:1531:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
checked program was:
/* begin */
 #include "ruby.h"

 #include <winsock2.h>
 #include <windows.h>
 int main(int argc, char **argv)
 {
   return 0;
 }
/* end */

如何解决此错误?

更新:我也试过了:

C:\Users\user1>gem install rmagick --version=2.13.3 --platform=ruby -- '--with-o
pt-lib="h:/ImageMagick-6.8.9-Q16/lib" --with-opt-include="h:/ImageMagick-6.8.9-Q
16/include"'

结果如下:

ERROR:  Could not find a valid gem 'rmagick' (= 2.13.3), here is why:
          Unable to download data from https://rubygems.org/ - no such name (htt
ps://rubygems.org/specs.4.8.gz)
ERROR:  Possible alternatives: rmagick

我仍然不知道为什么我会收到这些错误!

2 个答案:

答案 0 :(得分:2)

请按照以下链接中的步骤操作,您的链接似乎缺少dll链接

http://www.redmine.org/projects/redmine/wiki/HowTo_install_rmagick_gem_on_Windows

答案 1 :(得分:0)

这对我有用:

$ gem install rmagick --platform=ruby -- --with-opt-lib=C:/RailsInstaller/ImageMagick-6.7.7-Q8/lib --with-opt-include=c
:/RailsInstaller/ImageMagick-6.7.7-Q8/include 

请务必指定您自己的ImageMagick版本以及您在其中安装的文件路径。在命令

上包含lib文件夹