Mac Rmagick 2.13.2 错误:无法构建本地宝石扩展。

3

最近我把我的Mac升级到了El Capitan,并重新安装了(用Homebrew)ImageMagick 6.9.2-7。

不幸的是,bundle install无法工作,因为RMagick无法构建。

下面是调用堆栈:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby -r ./siteconf20151204-39308-uw4m6y.rb extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/local/opt/gcc46/bin/gcc-4.6... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.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
    --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/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
    from extconf.rb:194:in `<main>'

extconf failed, exit code 1

我尝试了互联网上发现的几种不同的解决方案,但似乎没有什么能够解决这个错误。

通过下面的操作,我始终收到上述错误:

1) C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.2-7/include/ImageMagick-6/ gem install rmagick -v '2.13.2'



2) gem install rmagick --version=2.13.2 --platform=ruby -- --with-opt-lib="h:/ImageMagick-6.9.2-7/lib" --with-opt-include="h:/ImageMagick-6.9.2-7/include"

3) $ cd /usr/local/Cellar/imagemagick/6.9.2-7/lib
$ ln -s libMagick++-Q16.6.dylib   libMagick++.dylib
$ ln -s libMagickCore-Q16.2.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.2.dylib libMagickWand.dylib

错误仍然相同:
The compiler failed to generate an executable file. (RuntimeError)

首先您需要安装开发工具。

我已经更新了Xcode到7.1.1版本。

我正在使用RVM的ruby-1.9.3-p327版本。

提前感谢您的帮助。


卸载pkg-config:brew uninstall pkg-config 安装pkg-config:brew install pkg-config 取消链接pkg-config并重新链接:brew unlink pkg-config && brew link pkg-config 仍未解决。 - HK15
你搞清楚了怎么解决这个问题吗?我也遇到了同样的问题。xcode-select --installbrew reinstall 步骤对我来说都没用... - agate
2个回答

2

您需要更新Xcode并安装命令行工具 (xcode-select --install)。


XCode已经更新,命令行工具也已经安装完成。 - HK15

1

对我来说,这些方法单独使用都没有起作用,但是将它们全部运行似乎解决了问题:

xcode-select --install
brew unlink imagemagick
brew uninstall --force imagemagick
brew update
brew doctor
brew install imagemagick

那可能有点过度,但最终对我起了作用。

我已经按照每一个步骤去做了,但是问题仍未解决。我的操作系统是Mac OS Mojave 10.14.6。请帮忙。 - Franva

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