在pkg-config搜索路径中找不到包MagickCore

时间:2016-07-05 09:37:28

标签: ruby-on-rails imagemagick rmagick

我正在尝试安装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

4 个答案:

答案 0 :(得分:34)

我有同样的问题。这项工作对我来说(Ubuntu):

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

答案 1 :(得分:22)

rmagick gem在安装时无法找到PKG_CONFIG_PATH。我们需要告诉ImageMagick的路径存在于何处。添加bash总是更好。

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

答案 2 :(得分:2)

CentOS的

yum install ImageMagick-devel

答案 3 :(得分:1)

这为我解决了这个问题:

sudo apt-get install libmagick++-dev