我已经在我的 CentOS 上编译了 ImageMagick,但不会安装 RMagick

Ken*_* Li 16 imagemagick rubygems

我安装了 ImageMagick,(使用 ImageMagick 6.7.3-7)

./configure --prefix=/usr && make && make install
Run Code Online (Sandbox Code Playgroud)

当我尝试

gem install imagemagick
Run Code Online (Sandbox Code Playgroud)

我得到

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
Run Code Online (Sandbox Code Playgroud)

尽管 MagickWand.h 已经在/usr/include/ImageMagick/wand/MagickWand.h. 所以问题是,我如何真正让编译器在那里查看?

Iro*_*com 25

使用最新的所有内容(截至 2011 年 12 月)在 CentOS 上遇到了同样的问题,并使用以下方法修复了它:

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
Run Code Online (Sandbox Code Playgroud)

在我的 .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
Run Code Online (Sandbox Code Playgroud)

瞧,MagickWand.h 被发现,MagickCore.pc 被捡起...... gem 安装成功。

我想另一种解决方案是修改 ImageMagick 安装过程中设置的配置选项,但我没有足够的系统管理员来清楚这些文件的正确选项和位置是什么。在 45 分钟的谷歌搜索之后,我无法弄清楚这些文件应该在哪里,由 gem install make 系统自动获取。

干杯!

编辑:2014-10-01

刚刚为 CentOS 7 再次执行此操作,并且ln不需要上述命令。但是,我遇到了“在 pkg-config 搜索路径中找不到 Package MagickCore”的问题。在跑步sudo gem install rmagick

问题是 /etc/sudoers 中的环境重置。在运行sudo visudo编辑 sudoers 文件后,我添加Defaults env_keep += "PKG_CONFIG_PATH"到适当的部分,更新安全路径以包含 /usr/local/bin,然后安装工作就像一个魅力。


小智 13

ImageMagick 通常会将 MagickCore 放在这里:

/usr/local/lib/pkgconfig/MagickCore.pc
Run Code Online (Sandbox Code Playgroud)

如果你的不在那里,你可以像这样找到它:

find / -name MagickCore.pc
Run Code Online (Sandbox Code Playgroud)

您现在知道您的 pkgconfig 路径:

/usr/local/lib/pkgconfig
Run Code Online (Sandbox Code Playgroud)

安装 gem 时设置环境:

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick
Run Code Online (Sandbox Code Playgroud)


小智 8

对于 CentOS,我通过安装“ImageMagick-devel”包解决了这个问题:

yum install ImageMagick-devel


jkh*_*jkh 2

关键是在配置输出中,它显示“检查 wand/MagickWand.h” - 显然 ImageMagick 目录不应该出现在 /usr/include 中,这意味着您需要将该目录的内容向上移动一个级别,或者您需要以不同方式安装 ImageMagick 本身。对于系统本身未提供的任何内容,将内容直接放入 /usr 通常是一个坏主意 - 如果您将在 /usr/local 中添加的所有内容分开,而将 /usr 大部分单独保留,您会发现系统更容易也可以进行管理,因为您将能够(在您忘记这一点很久之后)弄清楚您添加的内容与系统附带的内容。

  • 好吧,编译器调用都是通过 gem 命令发生的(您强制编译器使用 -I 标志查找替代位置,但该用户没有直接使用编译器),最好使用 configure 命令进行设置,例如善良的发生无需改变任何其他东西。如果有可用的 MagickCore.pc 文件,则使用配置不断尖叫的 PKG_CONFIG_PATH 环境变量可能会解决问题。“find /usr -name MagickCore.pc”,然后查看它是否存在,然后使用“setenv PKG_CONFIG_PATH /path/to/where/find/found/it”添加它所在的目录 (3认同)