简体   繁体   中英

How to install rmagick on windows 10

I am trying to install a gem which has rmagick as a dependency on windows 10. But each time I try to install it, this error appears:

ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160126-6648-ks1v6.rb extconf.rb --  with-opt-dir=C:/ImageMagick
*** 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)
extconf.rb:110:in ``': No such file or directory - identify -version    (Errno::ENOENT)
    from extconf.rb:110:in `configure_compile_options'
    from extconf.rb:16:in `initialize'
    from extconf.rb:517:in `new'
    from extconf.rb:517:in `<main>'

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
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir=C:/ImageMagick'
This could take a while...

I have even installed the gem imagemagick, but it doesn't allow me to install rmagick. How are you supposed to install rmagick on windows 10?

You have to use the correct version of ImageMagick, and have to reference that when you install the gem:

Here is the gem:

gem install rmagick --platform=ruby -- '--with-opt-dir="[path to ImageMagick]"'

Update

Here's a good reference

Here's how to install it step-by-step:

  1. Download & Install ImageMagick

在此处输入图片说明

There used to be a problem with newer versions of RMagick; we installed the version 6.9.2 , which is working on Win10 x64:

在此处输入图片说明

You need to make sure you have the above two checkboxes ticked ( C headers && system PATH ). The headers are used by the gem to compile (the likely reason for your error); PATH is used to call ImageMagick from the cmd.

You also need to make sure...

  • Install path has no spaces
  • You download dll version of ImageMagick (contains C Headers)
  • We got the HDRI version; it doesn't really matter

--

  1. Install the gem

Like mysql2 etc, you need to make sure you reference the installed libraries in order to get rmagick to install:

gem install rmagick --platform=ruby -- --with-opt-lib="c:/path_to_image_magick/lib" --with-opt-include="c:/path_to_image_magick/include"

This may take a while, but should install.

Make sure to use the 32-bit (ie x86) versions of ruby AND devkit. For some reason the build process for rmagick crashes with the 64-bit versions.

For anyone stumbling with this problem in 2021, I just installed the latest version of rmagick on Windows, using ImageMagick-6.9.12-33-Q16-HDRI-x64-dll

https://download.imagemagick.org/ImageMagick/download/binaries/

Steps:

Clean up your env variables (PATH) from any previous ImageMagick installation. This is important because the gem will look into each defined path for headers, previous configuration can pollute the installation (it happened to me). Uninstall everything.

  1. Run the installer, include C headers with the checkbox.
  2. Run gem install rmagick --platform=ruby -- '--with-opt-dir="C:\\Program Files\\ImageMagick-6.9.12-Q16-HDRI"' . Change the folder to your own.
  3. Make sure this folder has been added to your PATH
  4. To verify the installation, run convert . It should call the convert function.

For those wanting to install rmagick in a rails application instead, follow the same steps for ImageMagick, but manually add the PATH. This should be working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM