Buzz Simmons
Buzz Simmons

Reputation: 21

Ruby gem rmagick install failed

Problem installing a Ruby Gem..

Receive the following message

c:\>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
checking for Ruby version >= 1.8.5... yes
Version: ImageMagick 6.8.7-5 Q16 x86 2013-11-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps tiff webp x xml zlib

checking for stdint.h... "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Ruby193/lib -L.    -lCORE_RL_magick_ -lX11  -lmsvcrt-ruby191  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
c:/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lCORE_RL_magick_
c:/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lX11
c:/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lCORE_RL_magick_
c:/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lX11*** 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:/Ruby193/bin/ruby
C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
    from extconf.rb:194:in `<main>'
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

        C:/Ruby193/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:/Ruby193/bin/ruby
C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
    from extconf.rb:194:in `<main>'


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

any help greatly appreciated

Upvotes: 1

Views: 960

Answers (1)

Simon
Simon

Reputation: 11

I know that this is an old post but I have recently had this problem and this was one of posts I came across while looking for help before I figured out a solution. I wanted to come back and post an answer in the hope that it may help others because I didn't find this solution anywhere else.

The solution is twofold. First of all when you install ImageMagick you need to tick the box to install the libs & header files when prompted during the installation, then when you run gem install rmagick (assuming that you installed ImageMagick to C:\ImageMagick) you need to type:

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

This will tell it where the headers and libs are and get rid of the ld.exe: cannot find -lCORE_RL_magick_ error.

The second error you may still get if you installed more recent versions of ImageMagick. It seems that in recent installs of ImageMagick the devs have failed to include an important lib. If you look in your ImageMagick\lib directory you should see 4 files in there. The 3 CORE_RL*.lib files and also a x11.lib file. The x11.lib file is missing from recent versions (in my case version 6.9.0-6).

The solution is simple enough. Uninstall ImageMagick then download an older version from here.

In my case I used ImageMagick-6.7.7-0-Q16-windows-dll.exe. Install it and go in to the lib folder and copy the x11.lib file somewhere safe, then uninstall ImageMagick again and re-install whatever new version you want that has the missing file and just copy the file from your safe location to the ImageMagick lib directory.

Then run the gem install command above and it should work fine.

Upvotes: 1

Related Questions