Error Installing RMagick for Ruby on Rails on Windows

3.2k views Asked by At

I'm trying to install Ruby on Rails and Redmine on Xampp on my Windows 7. I successfully installed ImageMagick and RMagick following this link:

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

But when I run bundle install i get the following error:

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.

So I tried instaling rmagick 2.13.3 using this command:

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

But it also gave this error:

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

This is the mkmf.log file:

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 */

How can I fix this error?

UPDATE: I also tried this:

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"'

This is the result:

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

I still have no idea why I'm getting these errors!

2

There are 2 answers

7
pshoukry On BEST ANSWER

Please follow steps in the following link your link seems to be missing dll linking

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

0
coderwannabe2 On

This did the trick for me:

$ 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 

make sure to specify your own version of ImageMagick and the file path you installed it in & include the lib folder on the command