在Windows系统上安装RMagick

7

我针对这个问题进行了研究,在我的电脑上已经花费数小时来解决它。

大约3周前,我在桌面计算机上安装了RMagick,但过程相当复杂。

我不记得我采取的确切步骤,我真的很沮丧。

我将ImageMagick安装到了C:\ImageMagick目录下。

我还为Ruby安装了开发工具包。

我把rmagick-rmagick-v2-2-g564f157放入了正确的gems文件夹中,在我的C:盘里,路径为C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems。

我遇到了以下错误:

我会键入:gem install rmagick -- '--with-opt-dir="c:\ImageMagick"'

然后会得到以下错误:

Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir="c:\ImageMagick"'
This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160326-6132-157vnes.rb extconf.rb
'--with-opt-dir="c:\ImageMagick"
checking for main() in -lCORE_RL_magick_... no
searching PATH for the ImageMagick library...
checking for main() in -lCORE_RL_magick_... no
checking for main() in -lCORE_RL_magick_... no
checking for main() in -lCORE_RL_magick_... no
Can't install RMagick 2.15.4.
Can't find the ImageMagick library.
Retry with '--with-opt-dir' option.
Usage: gem install rmagick -- '--with-opt-dir="[path to ImageMagick]"'
e.g.
  gem install rmagick -- '--with-opt-dir="C:Program FilesImageMagick-6.9.1-
Q16"'
*** 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
        --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:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
        --with-CORE_RL_magick_lib
        --without-CORE_RL_magick_lib
        --with-CORE_RL_magick_lib
        --without-CORE_RL_magick_lib
        --with-CORE_RL_magick_lib
        --without-CORE_RL_magick_lib
        --with-CORE_RL_magick_lib
        --without-CORE_RL_magick_lib
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0
/gems/rmagick-2.15.4 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/rmagick-2.15.4/gem_make.out

我现在感到非常沮丧。它在我的台式电脑上可以工作,但在这里却无法运行。有什么建议吗?


派对已经结束了。看看这个答案,了解如何在Windows 10上安装rmagik - Adrian Moisa
2个回答

8

3
我认为这应该是正确的答案,因为它包含了在Windows上使其正常工作所需的所有信息和步骤。 - tiefenauer
在按照上述链接尝试了6.9.6和6.9.10后,我在安装过程中遇到了错误。https://pastebin.com/embed_iframe/6gMkPuNQ错误信息:无法构建本地扩展宝石。 - dinu1389
我在按照上面的链接进行安装后遇到了错误,尝试了6.9.6和6.9.10版本,但是出现了相同的错误,请参考以下链接:6.9.6: https://pastebin.com/embed_js/Ukjbyhq9 6.9.10: pastebin.com/embed_iframe/6gMkPuNQ错误信息:无法构建原生扩展的宝石。 - dinu1389
1
这个答案确实值得成为正确答案。完全解决了我的问题。谢谢。 - Sergio A.

7
我进行的安装步骤如下:
  1. 使用包括“开发头文件和库”的安装程序安装ImageMagick。请参见:http://www.graphity-consulting.com/files/2016/03/screenshot-installation-imagemagick-6.9.3-32bit-3.png
  2. 打开Windows命令提示符
  3. 增强路径以包括ImageMagick。例如:set PATH=d:\opt\ImageMagick;%PATH%
  4. 使用以下命令安装gem:gem install rmagick -- --with-opt-dir=d:\opt\ImageMagick

注意:我让gem自己下载rmagick,并在--with-opt-dir中传递ImageMagick路径,同时也将其添加到我的路径中。

更新:

正如@winter-young在评论中提到的那样:不要混合32位Ruby和64位ImageMagick或反之亦然。只使用32位Ruby与32位ImageMagick或使用64位Ruby与64位ImageMagick。

更新2:

如@winter-young所述,rmagick 2.15.4仅支持ImageMagick 6,而不支持ImageMagick 7(我自己没有测试)。

更新3:

如@tiefenauer所指出的,rmagic 2.16.0可与ImageMagick 7.0.8一起使用。此外,现在需要使用单引号:gem install rmagick -- '--with-opt-dir=C:\Program Files\ImageMagick-7.0.8-Q16'


2
在我的情况下,ld.exe 无法链接一个 imagemagick 库。我记不得库的名字了。这是因为 imagemagick 7 没有提供那个库。我必须使用 imagemagick 6。如果你使用 64 位的 ruby,你必须使用 64 位的 imagemagick。我使用了 32 位版本,它又失败了。 - Winter Young
3
请注意,只支持Imagemagick 6而不是7。Rmagic 2.15.4仅支持Imagemagick 6。 - Winter Young
@barlop 我还没有时间去研究你的问题。但是你尝试下面Tim的答案了吗? - Raul Pinto
@barlop 请保持更新。如果Tim的版本不起作用,我可以再试一次。 - Raul Pinto
2
我刚刚在Windows上安装了rmagick 2.16.0和ImageMagick 7.0.8-Q16,它的表现非常好。我不得不稍微调整了Raul的CLI命令:gem install rmagick -- '--with-opt-dir=C:\Program Files\ImageMagick-7.0.8-Q16'(请注意,在“--with-opt-dir”选项周围有单引号)。这在安装说明中指出。看起来这个版本的Rmagick可以与ImageMagick 7一起使用。 - tiefenauer
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接