ruby RMagick 安装:找不到 MagickWand.h
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39494672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
RMagick installation: Can't find MagickWand.h
提问by 0x4a6f4672
Updating RMagickand Imagemagickis a painful expierence. I have updated the Imagemagick version on my mac (MacOS El Capitan Version 10.11.5) with homebrew for one project in Ruby 2.3 to 6.9.5-9
更新RMagick和Imagemagick是一个痛苦的经历。我已经使用自制软件将我的 mac(MacOS El Capitan 版本 10.11.5)上的 Imagemagick 版本更新为 Ruby 2.3 中的一个项目6.9.5-9
$ convert --version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-09
Now an older project in Ruby 1.8.7 refuses to work with the error message "this installation of RMagick was configured with ImageMagick 6.8.9 but ImageMagick 6.9.5-9 is in use". Thus I uninstalled "rmagick", but it can not be installed again
现在,Ruby 1.8.7 中的一个旧项目拒绝使用错误消息“此 RMagick 安装配置为 ImageMagick 6.8.9,但正在使用 ImageMagick 6.9.5-9”。因此我卸载了“rmagick”,但无法再次安装
$ gem install rmagick -v 2.16.0
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
checking for /usr/local/opt/gcc46/bin/gcc-4.6... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... no
checking for sys/types.h... no
checking for wand/MagickWand.h... no
Can't install RMagick 2.16.0. Can't find MagickWand.h.
And if it can not be installed, the whole application can not be started. I tried all the answers from here, and none of them works on MacOS :-( I reinstalled imagemagick and pkg-config with homebrew, and tried various version of RMagick without success. 2.16.0 is the latest version of RMagickcurrently.
如果无法安装,则整个应用程序都无法启动。我尝试了这里的所有答案,但它们都不适用于 MacOS :-( 我用自制软件重新安装了 imagemagick 和 pkg-config,并尝试了各种版本的 RMagick,但没有成功。2.16.0 是当前最新版本的RMagick。
MagicWand seems to be used in ImageMagick version > 6.9, and it can be found on the machine:
MagicWand好像用在ImageMagick版本>6.9的,机器上可以找到:
find /usr/local -name MagickWand.h
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6/wand/MagickWand.h
find /usr/local -name MagickWand.pc
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/lib/pkgconfig/MagickCore.pc
It does not work even if I specifiy the these paths during the gem install (same error as above) :-(
即使我在 gem 安装期间指定了这些路径,它也不起作用(与上面的错误相同):-(
C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick
UPDATE:
更新:
The error only occurs for Ruby 1.8.7, it is possible to install RMagick for Ruby 2.0 and Ruby 2.3. Ruby 1.8.7 and ImageMagick 6.9.5 do not seem to be compatible.
该错误仅在 Ruby 1.8.7 上发生,可以为 Ruby 2.0 和 Ruby 2.3 安装 RMagick。Ruby 1.8.7 和 ImageMagick 6.9.5 似乎不兼容。
- Ruby 1.8.7 x
- Ruby 2.0.0 ?
- Ruby 2.3.1 ?
- 红宝石 1.8.7 x
- 红宝石 2.0.0 ?
- 红宝石 2.3.1 ?
采纳答案by 0x4a6f4672
Something was severely wrong on my system, so badly that it was completely f*d up, but I was finally to able to install RMagick for Ruby 1.8.7 again after I installed
我的系统出现了严重错误,严重到完全搞砸了,但我终于能够在安装后再次为 Ruby 1.8.7 安装 RMagick
- an older version of ImageMagick with Homebrew
- a new Ruby version of 1.8.7
- a new version of GCC
- 带有 Homebrew的旧版 ImageMagick
- 1.8.7 的新 Ruby 版本
- 新版本的 GCC
The installation of a new Ruby version with RVM rvm install 1.8.7also installed a new GCC compiler: it removed an older GCC version 4.6 and installed GCC version 4.9. Apparently GCC was not able to find the right headers despite pkg-config.
使用 RVMrvm install 1.8.7安装新的 Ruby 版本也安装了一个新的 GCC 编译器:它删除了旧的 GCC 4.6 版并安装了 GCC 4.9 版。显然,尽管有 pkg-config,GCC 还是无法找到正确的标头。
回答by K M Rakibul Islam
To solve the issue in Mac OSX Sierra, High Sierra, El Capitan, Mojave, and Catalina, you can do the following:
要解决Mac OSX Sierra、High Sierra、El Capitan、Mojave 和 Catalina 中的问题,您可以执行以下操作:
brew unlink imagemagick
brew install imagemagick@6 && brew link imagemagick@6 --force
imagemagick@6is keg-only, so you'll need to force linking.
imagemagick@6is keg-only,所以你需要强制链接。
回答by Raymond Cox
I had this same issue with ImageMagick 7.0.4-4. The proper fix is to install imagemagick@6. I found https://github.com/Homebrew/homebrew-core/pull/8756useful if you accidentally deleted your imagemagick@6or never had it installed in the first place.
我在ImageMagick 7.0.4-4 上遇到了同样的问题。正确的修复方法是安装imagemagick@6. 我发现https://github.com/Homebrew/homebrew-core/pull/8756如果您不小心删除了您的imagemagick@6或从未安装过它会很有用。
回答by Evgeniy28
macOs Sierra:
macOS 塞拉利昂:
brew uninstall imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force
回答by Ali Hassan Mirza
First of all unlink your installed imagemagick which was not properly installed in latest mac high sierra by using.
首先,使用未在最新 mac high sierra 中正确安装的已安装 imagemagick 取消链接。
brew unlink imagemagick
then install latest imagemagic6 using below command
然后使用以下命令安装最新的 imagemagic6
brew install imagemagick@6 && brew link imagemagick@6 --force
Then install gem rmagick using below command
然后使用以下命令安装 gem rmagick
gem install rmagick
It will work perfectly fine.
它会工作得很好。
回答by BMA88
yah this one solves my issue:
是的,这个解决了我的问题:
MacOS X Sierra:
MacOS X 塞拉利昂:
brew uninstall imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force
回答by Peter Toth - Toma
Many things have changed in ImageMagick 7 like this path: include/.../wand, and wand/MagickWand.his hardwired in the rmagic gem at the moment. In my case it was not possible to update the gem since the project is rather old. So I ended up installing an older version of ImageMagic.
ImageMagick 7 中的许多事情都发生了变化,例如这条路径:include/.../wand,并且wand/MagickWand.h目前在 rmagic gem 中是硬连线的。就我而言,由于项目相当陈旧,因此无法更新 gem。所以我最终安装了旧版本的 ImageMagic。
You can install the latest version from 6.x.x:
您可以从 6.xx 安装最新版本:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6f014f2b7f1f9e618fd5c0ae9c93befea671f8be/Formula/imagemagick.rb
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6f014f2b7f1f9e618fd5c0ae9c93befea671f8be/Formula/imagemagick.rb
You can also pin it for later usege:
brew pin imagemagick
您也可以将其固定以备后用:
brew pin imagemagick
回答by Holger Frohloff
Something changed with ImageMagick 7.0.4-4for me. wand/MagickWand.hcouldn't be found any more:
ImageMagick 7.0.4-4对我来说发生了一些变化。wand/MagickWand.h再也找不到了:
% brew unlink imagemagick && brew link imagemagick
Unlinking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks removed
Linking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks created
% gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/holger/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20170116-21103-1aikaka.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Can't install RMagick 2.16.0. Can't find MagickWand.h.
I still had ImageMagick 6.9.7-3 on my system and changed back with
我的系统上仍然有 ImageMagick 6.9.7-3 并改回来
% brew switch imagemagick 6.9.7-3
Cleaning /usr/local/Cellar/imagemagick/6.9.6-6
Cleaning /usr/local/Cellar/imagemagick/6.9.7-0
Cleaning /usr/local/Cellar/imagemagick/6.9.7-1
Cleaning /usr/local/Cellar/imagemagick/6.9.7-3
Cleaning /usr/local/Cellar/imagemagick/7.0.4-4
75 links created for /usr/local/Cellar/imagemagick/6.9.7-3
Afterwards I could install rmagickwithout trouble:
之后我可以rmagick毫无问题地安装:
% gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.16.0
1 gem installed
回答by Phil Calvin
RMagick depends on an outdated version of imagemagick, version 6.(see below)Homebrew offers this as a keg-only package, which you can install with:
RMagick 依赖于过时版本的 imagemagick,版本 6。(见下文)Homebrew 将其作为仅桶装的软件包提供,您可以安装:
brew install imagemagick@6
The build output will include a Caveatssection (also available from brew info imagemagick@6if you cleared the output):
构建输出将包括一个警告部分(brew info imagemagick@6如果您清除了输出也可以使用):
==> Caveats
imagemagick@6 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have imagemagick@6 first in your PATH run:
echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.zshrc
For compilers to find imagemagick@6 you may need to set:
export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include"
For pkg-config to find imagemagick@6 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
Rather than force-linking, which has the potential to cause problems with other software that doessupport newer versions of imagemagick, you can use the suggested exports to make the RMagick gem pick up the old version while it builds:
而不是武力联,这有可能造成问题与其他软件不支持ImageMagick的更新版本,您可以使用建议exports到使RMagick宝石拿起旧版本,而它建立:
export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
gem install rmagick
- Go help contribute to the upgrade effortif you know Ruby and C!
- 转到有助于促进升级的努力,如果你了解Ruby和C!
回答by Lalit Kumar Maurya
Please follow below and change some part according to your need.
请按照以下说明并根据您的需要更改某些部分。
brew unlink imagemagick
brew install imagemagick@6 && brew link imagemagick@6 --force
export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick@6/6.9.9-24/lib/pkgconfig
gem install rmagick -v '2.15.4'
回答by Yury Lebedev
$ brew remove imagemagick && brew install imagemagick
$ brew uninstall pkg-config && brew install pkg-config
$ brew unlink pkg-config && brew link pkg-config
$ gem install rmagick

