3

I'm having trouble getting rmagick to work on windows. Does anyone know how to get this working correctly? And even better, hopefully in a way that is compatible with a production environment, although I'll take whatever I can get.

C:\> gem install rmagick --platform=ruby -- --with-opt-lib=%IMAGE_MAGICK_HOME%/lib --with-opt-include=%IMAGE_MAGICK_HOME%/include
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.

        c:/ruby192/bin/ruby.exe extconf.rb --with-opt-lib=C:\Program Files (x86)\ImageMagick-6.7.0-Q16/lib --with-opt-include=C:\Program Fil
es (x86)\ImageMagick-6.7.0-Q16/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:/ruby192/bin/ruby
c:/ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate 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 postpone'
        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:193:in `<main>'


Gem files will remain installed in c:/ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1 for inspection.
Results logged to c:/ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
Fire Emblem
  • 5,961
  • 3
  • 24
  • 37
  • @Zabba: With the devkit, it won't install properly. It needs libraries that it can't find. I've tried to download imagemagick and rmagick and compile them, but it fails when I try to compile rmagick. The devkit just isn't doing what it's supposed to do I don't think. Basically, `gem install rmagick` doesn't 'just work' - far from it :/ – Fire Emblem Jun 03 '11 at 23:59

2 Answers2

4

Answer in this thread made it work on both of my computer: RMagick on Windows

I hope it'll work for you too !

Community
  • 1
  • 1
Lucas
  • 2,886
  • 1
  • 27
  • 40
  • I did most of that. I will paste the error. Man, I wish this was easier. Rmagick is something most people will want. I wish the devkit provided some help by default. This is too hard for each and every person to go through :( – Fire Emblem Jun 04 '11 at 00:19
  • finally got it to work. i dunno what i did actually. it just started working. – Fire Emblem Jun 04 '11 at 01:59
0

For future reference: I just installed rmagick into Ruby 2.1-x64 on Windows using instructions from a reddit post, reposted below:


Download the Ruby Development Kit from http://rubyinstaller.org/downloads/ and unpack it somewhere. (By the way, your Ruby must also have come from Rubyinstaller otherwise the dev kit says it won't work.)

Init your DevKit by doing

dk.rb init

this will create a config.yml with a list of Rubies found on your system, you may edit it and delete the ones you don't care about

dk.rb review

to make sure the previous step went well

dk.rb install

to install DevKit into that Ruby, after this is done you'll be able to compile native Ruby extensions.

Download ImageMagick from Link (ImageMagick-6.9.2-3-Q16-x64-dll.exe worked for me), and install it to a path without spaces. Make sure to check Add application directory to system path and Install headers and libraries for C and C++.

Restart your command line window to make sure the change to PATH took.

Do a quick set PATH to make sure ImageMagick is first in PATH, otherwise the install will fail (because an install script calls convert.exe which is from ImageMagick, but there also exists a C:\Windows\system32\convert.exe).

Run the following line, suitably replacing with the location of ImageMagick on your system (which, you remember, should not contain spaces):

gem install rmagick --platform=ruby -- --with-opt-lib=D:/Tools/ImageMagick-6.9.2-Q16/lib --with-opt-include=D:/Tools/ImageMagick-6.9.2-Q16/include --with-opt-dir=D:/Tools/ImageMagick-6.9.2-Q16

It should churn for a couple of minutes and then you're golden.

By the way, as long as you intend to be using RMagick, you're stuck with having ImageMagick in your PATH.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109