无法安装rmagick,pkg-config命令未找到。

21

我正在尝试在我的Mac OS X v10.9(Mavericks)机器上安装rmagick。但是,我遇到了这个错误。

/usr/local/bin/Magick-config: line 41: pkg-config: command not found
/usr/local/bin/Magick-config: line 47: pkg-config: command not found
/usr/local/bin/Magick-config: line 50: pkg-config: command not found
/usr/local/bin/Magick-config: line 53: pkg-config: command not found
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... yes
/usr/local/bin/Magick-config: line 53: pkg-config: command not found
Can't install RMagick 2.13.2. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.

Magick-config中的41、17、50、53行是:

--cflags)
  pkg-config --cflags MagickCore
  ;;
--cxxflags)
  pkg-config --cflags MagickCore
  ;;
--cppflags)
  pkg-config --cflags MagickCore
  ;;
--ldflags)
  pkg-config --libs MagickCore
  ;;
--libs)
  pkg-config --libs MagickCore
  ;;

我使用brew install imagemagick --build-from-source安装了ImageMagick,然后在运行gem install rmagick之前,我使用export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.8.9-1/lib/pkgconfig设置了MagickCore.pc的路径以及使用export C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.9-1/include/ImageMagick-6/设置了Wand.h的路径。这对于Wand有效,但对于MagickCore无效,因为我仍然收到“pkg-config:command not found”的错误。
我使用Ruby 1.9.3p545和Ruby on Rails 3.2.16。
如何解决这个问题?

看起来你需要安装 pkg-config 或更新 PATH 以包含它的位置。从源代码构建时,需要在系统上安装此实用程序。 - emcconville
pkg-config 已经随 Homebrew 安装好了。你想让我更新哪个 PATH - Minh Tri Pham
1
你确定 pkg-config 在你指定的位置吗?使用 which pkg-config 进行检查。对我来说,在 macOS 10.7.5 上,它位于 /usr/local/bin/pkg-config - Eric Baldwin
3个回答

66

升级到Maverick后,我也遇到了Rmagick的同样问题。这个解决方法有效:

brew uninstall pkg-config
brew install pkg-config
brew unlink pkg-config && brew link pkg-config

2
在我的情况下,brew uninstall pkg-config 失败了,所以我只运行了 brew install pkg-config,这解决了我的问题。 - Lyndsey Ferguson
太棒了!!!! 在尝试了所有其他 StackOverflow 的解决方案几个小时后,这终于让我安装 rmagick gem 成功了。谢谢! - Raymond Gan

21

重新安装 pkg-config 解决了我的问题。


10

brew install pkg-config 对我有用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接