1

安装 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

非常感谢任何帮助

4

1 回答 1

1

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

解决方案是双重的。首先,当您安装 ImageMagick 时,您需要在安装过程中出现提示时勾选安装库和头文件的框,然后在运行时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 中,开发人员未能包含一个重要的库。如果您查看您的ImageMagick\lib目录,您应该会在其中看到 4 个文件。3个CORE_RL*.lib文件,还有一个x11.lib文件。x11.lib最新版本(在我的情况下为 6.9.0-6 版)中缺少该文件。

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

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

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

于 2015-02-17T17:08:10.847 回答