如何让 rmagick 在带有 Rails 3.1 和 Carrierwave 的 Windows 7 64 位上工作?
我无法让 rmagick 在 Windows 上工作。有谁知道如何让它正常工作?更好的是,希望以一种与生产环境兼容的方式,尽管我会尽我所能。
C:\> gem install rmagick --platform=ruby -- --with-opt-lib=%IMAGE_MAGICK_HOME%/lib --with-opt-include=%IMAGE_MAGICK_HOME%/include
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
c:/ruby192/bin/ruby.exe extconf.rb --with-opt-lib=C:\Program Files (x86)\ImageMagick-6.7.0-Q16/lib --with-opt-include=C:\Program Fil
es (x86)\ImageMagick-6.7.0-Q16/include
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=${opt-dir}/include
--with-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/ruby192/bin/ruby
c:/ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
from extconf.rb:193:in `<main>'
Gem files will remain installed in c:/ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1 for inspection.
Results logged to c:/ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
I'm having trouble getting rmagick to work on windows. Does anyone know how to get this working correctly? And even better, hopefully in a way that is compatible with a production environment, although I'll take whatever I can get.
C:\> gem install rmagick --platform=ruby -- --with-opt-lib=%IMAGE_MAGICK_HOME%/lib --with-opt-include=%IMAGE_MAGICK_HOME%/include
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
c:/ruby192/bin/ruby.exe extconf.rb --with-opt-lib=C:\Program Files (x86)\ImageMagick-6.7.0-Q16/lib --with-opt-include=C:\Program Fil
es (x86)\ImageMagick-6.7.0-Q16/include
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=${opt-dir}/include
--with-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/ruby192/bin/ruby
c:/ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:834:in `block in have_header'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from c:/ruby192/lib/ruby/1.9.1/mkmf.rb:833:in `have_header'
from extconf.rb:193:in `<main>'
Gem files will remain installed in c:/ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1 for inspection.
Results logged to c:/ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该线程中的答案使其在我的两台计算机上都能工作: Windows 上的 RMagick
我希望它也适合您!
Answer in this thread made it work on both of my computer: RMagick on Windows
I hope it'll work for you too !
供将来参考:我刚刚按照 Reddit 帖子中的说明将 rmagick 安装到 Windows 上的 Ruby 2.1-x64 中,重新发布如下:
从 http://rubyinstaller.org/downloads/ 并将其解压到某个地方。 (顺便说一句,您的 Ruby 也必须来自 Rubyinstaller,否则开发工具包会说它无法工作。)
通过执行此操作初始化您的 DevKit
将创建一个 config.yml,其中包含系统上找到的 Rubies 列表,您可以编辑并删除您不关心的那些,
以确保上一步顺利地
将 DevKit 安装到该 Ruby 中,完成此操作后,您将能够编译本机 Ruby 扩展。
从 链接 下载 ImageMagick (ImageMagick-6.9.2-3-Q16-x64 -dll.exe 对我有用),并将其安装到不带空格的路径。确保选中将应用程序目录添加到系统路径和安装 C 和 C++ 的头文件和库。
重新启动命令行窗口以确保对 PATH 的更改生效。
快速设置 PATH 以确保 ImageMagick 位于 PATH 的第一位,否则安装将失败(因为安装脚本调用来自 ImageMagick 的 Convert.exe,但也存在 C:\Windows\system32\convert.exe)。
运行以下行,适当地替换为系统上 ImageMagick 的位置(记住,不应包含空格):
它应该会搅拌几分钟,然后就可以了。
顺便说一句,只要您打算使用 RMagick,您就必须在 PATH 中包含 ImageMagick。
For future reference: I just installed rmagick into Ruby 2.1-x64 on Windows using instructions from a reddit post, reposted below:
Download the Ruby Development Kit from http://rubyinstaller.org/downloads/ and unpack it somewhere. (By the way, your Ruby must also have come from Rubyinstaller otherwise the dev kit says it won't work.)
Init your DevKit by doing
this will create a config.yml with a list of Rubies found on your system, you may edit it and delete the ones you don't care about
to make sure the previous step went well
to install DevKit into that Ruby, after this is done you'll be able to compile native Ruby extensions.
Download ImageMagick from Link (ImageMagick-6.9.2-3-Q16-x64-dll.exe worked for me), and install it to a path without spaces. Make sure to check Add application directory to system path and Install headers and libraries for C and C++.
Restart your command line window to make sure the change to PATH took.
Do a quick set PATH to make sure ImageMagick is first in PATH, otherwise the install will fail (because an install script calls convert.exe which is from ImageMagick, but there also exists a C:\Windows\system32\convert.exe).
Run the following line, suitably replacing with the location of ImageMagick on your system (which, you remember, should not contain spaces):
It should churn for a couple of minutes and then you're golden.
By the way, as long as you intend to be using RMagick, you're stuck with having ImageMagick in your PATH.