在pkg-config的搜索路径中未找到MagickCore包。

42

我试图安装rmagick,但它总是提示未配置PKG_CONFIG_PATH

这种情况多次发生在我身上,所以我将其发布为一个问题,并为任何遇到相同问题的人提供答案。

User-MacBook-Pro:rsscom macuser$ gem install rmagick -v '2.13.3'
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

    /Users/macuser/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20160705-63310-klqxmw.rb 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
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 0.0.0. 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=/Users/macuser/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)

extconf failed, exit code 1

Gem files will remain installed in /Users/macuser/.rvm/gems/ruby-2.2.0/gems/rmagick-2.13.3 for inspection.
Results logged to /Users/macuser/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0-static/rmagick-2.13.3/gem_make.out

6
在 macOS 上安装 ImageMagick,命令为 brew install imagemagick。参考链接为 https://dev59.com/EWkw5IYBdhLWcg3wMHyn。 - Jeremy Cochoy
3
根据你的rmagick版本,你可能需要安装imagemagick v6: brew install imagemagick@6 && brew link imagemagick@6 --force - Capripot
4个回答

78

我也遇到了同样的问题。这个方法对我有用(在Ubuntu上):

sudo apt-get install libmagickwand-dev

31

rmagick gem 在安装时无法找到 PKG_CONFIG_PATH。我们需要告诉它 ImageMagick 的路径在哪里。最好将其添加到 bash 中。

export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.3-7/lib/pkgconfig

жњЂиү‘зљ„Homebrew安иӘ…зљ„imagemagick@6е°†е…·жњ‰д»Өдё‹еҮәе‡ғи·Үең„пәљ export PKG_CONFIG_PATH="/opt/homebrew/opt/imagemagick@6/lib/pkgconfig" иүђиҰЊbrew infoд»ӨиҺ·еЏ–дёҺ您的安иӘ…з›ёе…ізљ„еҮәе‡ғи·Үең„гЂ‚ - Dylan Fisher

21

这对我解决了问题(在Ubuntu 18.04上有效):

sudo apt-get install libmagick++-dev

这对我来说起作用了,针对相关的“在 pkg-config 搜索路径中未找到包 Magick++”错误。 - Scriddie

6

CentOS

yum install ImageMagick-devel

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