ruby 无法安装 RMagick 2.13.1。找不到 MagickWand.h。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9050419/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 04:43:22  来源:igfitidea点击:

Can't install RMagick 2.13.1. Can't find MagickWand.h.

rubyinstallrmagick

提问by blawzoo

When I try do install rmagick I get the following error message:

当我尝试安装 rmagick 时,我收到以下错误消息:

Can't install RMagick 2.13.1. Can't find MagickWand.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.

I'm on Mac OSX 10.6.8, ruby 1.9.2p290, rvm 1.10.2.

我使用的是 Mac OSX 10.6.8、ruby 1.9.2p290、rvm 1.10.2。

Can anyone help me please to solve this problem.

谁能帮我解决这个问题。

采纳答案by Darren Cheng

I had a similar issue with running

我在跑步时遇到了类似的问题

$ gem install rmagick

First of all, do you have imagemagick installed? If you're not sure, run

首先,你有没有安装imagemagick?如果您不确定,请运行

$ convert --version

If you do, you probably either installed it with fink or macports (maybe homebrew?). What is happening is that rvm can't find the imagemagick directory.

如果你这样做了,你可能是用 fink 或 macports(也许是自制软件?)安装了它。发生的事情是 rvm 找不到 imagemagick 目录。

After reading https://superuser.com/questions/361435/i-have-compiled-imagemagick-on-my-centos-and-rmagick-wont-installI exported the imagemagick path by adding

阅读 https://superuser.com/questions/361435/i-have-compiled-imagemagick-on-my-centos-and-rmagick-wont-install 后,我通过添加导出了 imagemagick 路径

$ export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"

to my ~/.bash_profile, sourcing the new profile, then running:

到我的 ~/.bash_profile,获取新的配置文件,然后运行:

gem install rmagick

It worked for me after I did this.

在我这样做之后它对我有用。

回答by SporkInventor

If you're on Ubuntu, installing this package is what fixed it for me:

如果你在 Ubuntu 上,安装这个包就是为我修复它的原因:

sudo apt-get install libmagickwand-dev

回答by shigeya

It looks like ImageMagick 7 changed include file path.

看起来 ImageMagick 7 更改了包含文件路径。

On building rmagick, since it includes file as wand/MagickWand.hThere are no workarounds. It looks like sticking with ImageMagick 6 for now.

在构建时rmagick,因为它包含文件,因为wand/MagickWand.h没有解决方法。现在看起来像坚持使用 ImageMagick 6。

On Mac OS X (I tested on Sierra), I used HomeBrew's versionstap like:

在 Mac OS X 上(我在 Sierra 上测试过),我使用了 HomeBrew 的versions水龙头,例如:

brew tap homebrew/versions
brew install imagemagick@6

Then, use the path shown on above installation:

然后,使用上面安装中显示的路径:

PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

To install with ImageMagick 6.

与 ImageMagick 6 一起安装。

回答by Fiona Hopkins

I didn't want to mess with environment variables since I wanted bundler to be able to compile this gem on its own on a CI machine. Instead, I used Homebrew to install pkg-config:

我不想弄乱环境变量,因为我希望 bundler 能够在 CI 机器上自己编译这个 gem。相反,我使用 Homebrew 来安装 pkg-config:

brew install pkgconfig

brew install pkgconfig

and the next time I tried compiling the RMagick gem it found the header file without issue.

下次我尝试编译 RMagick gem 时,它发现头文件没有问题。

(This is pkg-config 0.28, ImageMagick 6.8.0-10, and RMagick 2.13.2, all on Mountain Lion.)

(这是 pkg-config 0.28、ImageMagick 6.8.0-10 和 RMagick 2.13.2,都在 Mountain Lion 上。)

回答by xonico

fix this setting the include path of your current imagemagick installation:

修复此设置当前 imagemagick 安装的包含路径:

Install ImageMagick with brew

使用 brew 安装 ImageMagick

brew install imagemagick

find library

找图书馆

$ mdfind MagickWand.h
/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/wand/MagickWand.h

Install rmagick gem

安装 rmagick gem

$ C_INCLUDE_PATH=/path/MagickWand.h gem install rmagick

example:

例子:

$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.5-7/include/ImageMagick/ gem install rmagick

回答by tobinjim

I marked this as a favorite because it seems to come back to bite me with every new system I need to install RMagick on (and time has passed and version numbers have rolled).

我将此标记为最喜欢的,因为它似乎会在我需要安装 RMagick 的每个新系统上再次咬我(时间已经过去,版本号已经滚动)。

Mac OS X 10.8.4

Mac OS X 10.8.4

rvm 1.22.3

房车 1.22.3

ruby-2.0.0-p247

红宝石-2.0.0-p247

Xcode 4.6.3 developer tools installed

已安装 Xcode 4.6.3 开发人员工具

$ brew install imagemagick
==> /usr/local/Cellar/imagemagick/6.8.6-3

$ brew install pkgconfig
==> /usr/local/Cellar/pkg-config/0.28

$ C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.6-3/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.8.6-3/lib/pkgconfig/ gem install rmagick
Successfully installed rmagick-2.13.2

Many thanks to everyone who added helpful answers above!

非常感谢所有在上面添加有用答案的人!

回答by Adam Grant

Mac users using brew

使用 brew 的 Mac 用户

If you can use v6 of ImageMagick instead of 7, you can try this

如果你可以使用 ImageMagick 的 v6 而不是 7,你可以试试这个

brew install imagemagick@6 --force && brew link imagemagick@6 --force

Note this will unlink your existing IM installation, so be careful if you have other projects on your machine using ImageMagick without problems.

请注意,这将取消链接您现有的 IM 安装,因此如果您的机器上有其他项目使用 ImageMagick 没有问题,请小心。

回答by fregas

For my own and others edification, I got past the error about the magicwand.h by using the suggestion xonico. MDFind plus the C_INCLUDE_PATH. However, it then gave me an error about MagickCore.pc. My final command to get this working had to include both like so:

对于我自己和其他人的启发,我通过使用建议 xonico 克服了关于 magicwand.h 的错误。MDFind 加上 C_INCLUDE_PATH。然而,它给了我一个关于 MagickCore.pc 的错误。我让这个工作的最终命令必须包括两者,如下所示:

 C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/lib/pkgconfig/ gem install rmagick

Obviously your paths will vary depending on whether you're using brew like me and what version of imagemagick you were installing. Also, xcode command line tools did have to be installed, as others have mentioned.

显然,您的路径会有所不同,具体取决于您是否像我一样使用 brew 以及您安装的是什么版本的 imagemagick。此外,正如其他人提到的那样,确实必须安装 xcode 命令行工具。

Thanks for everyone's posts on this! I am plussing your answers since it contributed to mine!

感谢大家在这方面的帖子!我很高兴你的答案,因为它对我的做出了贡献!

回答by rusllonrails

For Ubuntu:

对于 Ubuntu:

sudo apt-get install imagemagick libmagickwand-dev
gem install rmagick

回答by user81620

I had a problem after update to Maverics. It have lost a lot of linkings. In my case I had to refresh links to pkg-config

更新到 Maverics 后我遇到了问题。它失去了很多链接。就我而言,我必须刷新 pkg-config 的链接

brew unlink pkg-config
brew link pkg-config

Then installing rmagick worked like a charm.

然后安装 rmagick 就像一个魅力。