我通过以下方式安装了 ImageMagick(使用 ImageMagick 6.7.3-7)
./configure --prefix=/usr && make && make install
当我尝试
gem install imagemagick
我明白了
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
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.
Provided configuration options:
--with-opt-dir
--without-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=/usr/bin/ruby
尽管 MagickWand.h 已经在系统中了/usr/include/ImageMagick/wand/MagickWand.h
。那么问题是,我如何才能让编译器查看那里的内容呢?
答案1
在 CentOS 上使用最新版本(截至 2011 年 12 月)时遇到了同样的问题,并使用以下命令修复了它:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
在我的 .bashrc 文件中获取 MagickCore.pc,然后创建两个符号链接:
ln -s /usr/local/include/ImageMagick/wand /usr/local/include/wand
ln -s /usr/local/include/ImageMagick/magick /usr/local/include/magick
瞧,找到了 MagickWand.h,选择了 MagickCore.pc... gem 安装成功。
我想另一个解决方案是修改 ImageMagick 安装期间设置的配置选项,但我不是系统管理员,不清楚这些文件的正确选项和位置是什么。经过 45 分钟的谷歌搜索,我还是搞不清楚这些文件在哪里应该存活,被 gem install make 系统自动拾取。
干杯!
编辑:2014-10-01
刚刚又为 CentOS 7 做了一遍,ln
上面的命令就不需要了。但是,我遇到了一个问题,在运行 时,出现了“在 pkg-config 搜索路径中未找到 MagickCore 包。” sudo gem install rmagick
。
问题是 /etc/sudoers 中的环境重置。运行sudo visudo
编辑 sudoers 文件后,我添加了Defaults env_keep += "PKG_CONFIG_PATH"
相应的部分,更新了安全路径以包含 /usr/local/bin,然后安装就顺利完成了。
答案2
ImageMagick 通常会将 MagickCore 放在这里:
/usr/local/lib/pkgconfig/MagickCore.pc
如果你的不在那里,你可以通过以下方式找到它:
find / -name MagickCore.pc
您现在知道您的 pkgconfig 路径:
/usr/local/lib/pkgconfig
安装gem时设置环境:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick
答案3
对于 CentOS,我通过安装“ImageMagick-devel”包解决了这个问题:
yum install ImageMagick-devel
答案4
您可能需要为您的发行版安装适当的支持包: http://rpmfind.net/linux/rpm2html/search.php?query=pkgconfig%28MagickCore%29
在 CentOS 上遇到了完全相同的问题,rmagick
之后安装成功yum install ImageMagick-devel