installing rmagick with mingw and ruby 1.9

Think I finally got it to work.

1) install ImageMagick from source using mingw, like (in msys bash) ./configure –prefix=/c/imagemagick –disable-perl && make && make install

http://www.waydotnet.com/blog/2010/02/rmagick-on-ruby-1-9-1-i386-mingw32-work-d/

lists a much easier way to do it (assuming you have the devkit installed):

install ImageMagick somewhere (with headers option checked, and yes add it to your path) (ImageMagick-6.6.2-Q16 known to work).

C:\> set CPATH=D:\installs\ImageMagick-6.6.2-Q16\include
C:\> set LIBRARY_PATH=D:\installs\ImageMagick-6.6.2-Q16\lib
C:\> gem install rmagick

Though he does list a few more steps that might be useful…

Note that it needs to be in a path with no spaces, or see the comments on how to use the short pathnames.

14 thoughts on “installing rmagick with mingw and ruby 1.9

  1. c:/ruby19/lib/ruby/gems/1.9.1/gems/rmagick-2.12.2/lib/RMagick.rb:1944:in `from_color': invalid color name: lightcyan2 (ArgumentError)
    from c:/ruby19/lib/ruby/gems/1.9.1/gems/rmagick-2.12.2/lib/RMagick.rb:1944:in `initialize’
    from rmagick_installed_test.rb:6:in `new’
    from rmagick_installed_test.rb:6:in `

    meant “somehow or other you linked against an imagemagick that was old or outdated or incomplete or somefin–for me on mingw, recompiling it from scratch and using that version worked splendidly, though there are probably other options”

  2. “gcc -o conftest -Ic:/ruby19/include/ruby-1.9.1/i386-mingw32 -Ic:/ruby19/include/ruby-1.9.1/ruby/backward -Ic:/ruby19/include/ruby-1.9.1 -I. -I/c/rdp/installsc:\rdp\installs\imagemagick/include/ImageMagick -D_DLL -D_MT -I/c/rdp/installsc:\rdp\installs\imagemagick/include/ImageMagick
    -D_DLL -D_MT conftest.c -L. -Lc:/ruby19/lib -L/c/rdp/installsc:\rdp\installs\imagemagick/lib -L/c/rdp/installsc:\rdp\installs\imagemagick/lib -lMagickCore -lgdi32 -lm -lmsvcrt-ruby191-static -lshell32 -lws2_32 ”
    checked program was:
    /* begin */
    1: #include “ruby.h”
    2:
    3: #include
    4: #include
    5: int main() {return 0;}
    /* end */

    checked program was:
    /* begin */
    1: #include
    /* end */

    failing meant “you need to have mingw friendlier paths in there -Lc:/something for whatever cruddy reason”

  3. /home/rdp/i386/gemrepository/gems/rmagick-2.12.2/lib/RMagick2.so: [BUG] Segmentation fault
    ruby 1.8.7 (2009-3-4 mbari 8B/0x8770 on patchlevel 72) [i686-linux]

    Aborted

    meant “you are trying to use a binary compiled with a different version of ruby”

  4. same with

    rmagick (2.12.2)
    [20:2048][rdp@ilab1:/tmp/rdp/p2pwebclient/src]$ ruby singleMultipleGraphs.rb unnamed316651_at6
    /home/rdp/i386/gemrepository/gems/rmagick-2.12.2/lib/RMagick2.so: [BUG] unknown type 0x22 (0xc given)
    ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]

    — control frame ———-
    c:0040 p:—- s:0132 b:0132 l:000131 d:000131 CFUNC :initialize
    c:0039 p:—- s:0130 b:0130 l:000129 d:000129 CFUNC :initialize
    c:0038 p:-36542642 s:0128 b:0128 l:000127 d:000127 TOP
    c:0037 p:—- s:0126 b:0126 l:000125 d:000125 CFUNC :require
    c:0036 p:0048 s:0122 b:0122 l:000121 d:000121 METHOD /tmp/rdp/p2pwebclient/src/unique_require.rb:21
    c:0035 p:0011 s:0115 b:0115 l:000114 d:000114 TOP /home/rdp/i386/gemrepository/gems/rmagick-2.12.2/lib/RMagick.rb:11

  5. Pingback: puts WaYdotNET => Carlo Bertini » RMagick on Ruby 1.9.1 (i386-mingw32) Work !!! :D

  6. >gem install rmagick
    Building native extensions. This could take a while…
    ERROR: Error installing rmagick:
    ERROR: Failed to build gem native extension.

    D:/ruby18/bin/ruby.exe extconf.rb
    checking for Ruby version >= 1.8.5… yes
    Unable to get ImageMagick version
    *** extconf.rb failed ***

    meant “you want to install it from the source, see original post”

  7. C:\dev>gem install rmagick
    Building native extensions. This could take a while…
    ERROR: Error installing rmagick:
    ERROR: Failed to build gem native extension.

    C:/installs/ruby191p376/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:/installs/ruby191p376/bin/ruby
    C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:364:in `try_do': The complier failed to generate an executable file. (RuntimeError)
    You have to install development tools first.
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:433:in `try_cpp’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:811:in `block in have_header’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:670:in `block in checking_for’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:276:in `block (2 levels) in postpone’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:250:in `open’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:276:in `block in postpone’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:250:in `open’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:272:in `postpone’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:669:in `checking_for’
    from C:/installs/ruby191p376/lib/ruby/1.9.1/mkmf.rb:810:in `have_header’
    from extconf.rb:193:in `’

    Gem files will remain installed in C:/installs/ruby191p376/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1 for inspection.
    Results logged to C:/installs/ruby191p376/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

    meant “you installed ImageMAgick without the development headers checkbox checked!”

  8. Also note that when you install imagemagick you should install it to a directory without any space in its name. Thus the default c:\program files(x86) won’t be good. Or if you install it there create an alias (symlink) with “MKLINK /d c:\progx86 c:\program files(x86)” and then set CPATH and LIBRARY_PATH to use this new aliased directory. Then it will compile just fine and dandy :)

    MKLINK only works in vista and windows 7(!)

    All in all it’s not that difficult at all. Few simple steps and that’s it. It compiled and installed under 3 minutes on my not too new core2 duo laptop w/ 4 gigs of ram on win 7 ultimate

  9. You can use the short file names for paths with spaces.

    C:\Users\gthiesfeld\Work\repo>dir /x “C:\Pr*”
    Volume in drive C has no label.
    Volume Serial Number is 2EEC-9EED

    Directory of C:\

    10/06/2010 08:55 AM PROGRA~1 Program Files
    11/03/2010 09:36 AM PROGRA~2 Program Files (x86)
    0 File(s) 0 bytes
    3 Dir(s) 21,074,919,424 bytes free

    C:\Users\gthiesfeld\Work\repo>set CPATH=C:/Progra~2/ImageMagick-6.6.5-Q16/include

    C:\Users\gthiesfeld\Work\repo>set LIBRARY_PATH=C:/Progra~2/ImageMagick-6.6.5-Q16/lib

  10. I fought with installing Rmagick for DAYS on Windows 7 with no luck! rdp-rmagick works wonderfully!

    How did you know about that gem? Where would I find that out? I googled everything possible for a solution to installing rmagick gem.

Leave a Reply

Your email address will not be published. Required fields are marked *


five × 6 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>