Ruby gem rmagick安装失败

时间:2013-11-08 14:17:42

标签: ruby

安装Ruby Gem的问题..

收到以下消息

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

任何帮助非常感谢

1 个答案:

答案 0 :(得分:1)

我知道这是一个老帖子,但我最近遇到了这个问题,这是我在找到解决方案之前寻找帮助时遇到的帖子之一。我想回来发一个答案,希望它可以帮助别人,因为我在其他任何地方都找不到这个解决方案。

解决方案是双重的。首先,当你安装ImageMagick时,你需要勾选方框来安装libs&amp;在安装过程中出现提示时的头文件,然后当您运行gem install rmagick时(假设您已将ImageMagick安装到C:\ImageMagick),您需要输入:

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

这将告诉它标题和库的位置并消除ld.exe: cannot find -lCORE_RL_magick_错误。

如果您安装了更新版本的ImageMagick,可能仍会遇到第二个错误。似乎在最近安装的ImageMagick中,开发人员未能包含重要的lib。如果你查看ImageMagick\lib目录,你应该看到4个文件。 3 CORE_RL*.lib个文件以及x11.lib个文件。最近版本中缺少x11.lib文件(在我的案例中为6.9.0-6版)。

解决方案很简单。卸载ImageMagick,然后从here下载旧版本。

就我而言,我使用了ImageMagick-6.7.7-0-Q16-windows-dll.exe。安装它并进入lib文件夹并将x11.lib文件复制到安全的地方,然后再次卸载ImageMagick并重新安装任何有缺少文件的新版本,只需从您的文件中复制文件即可ImageMagick lib目录的安全位置。

然后运行上面的gem install命令,它应该可以正常工作。