3

我搜索了这个问题并不断寻找与 PC 相关的资源。

每次我尝试安装 EventMachine 时都会收到此错误:

Building native extensions.  This
could take a while... ERROR:  Error
installing eventmachine:  ERROR:
Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for rb_trap_immediate in
ruby.h,rubysig.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/local/bin/ruby
/usr/local/lib/ruby/1.9.1/mkmf.rb:368:in
`try_do': The complier failed to
generate an executable file.
(RuntimeError) You have to install
development tools first.  from
/usr/local/lib/ruby/1.9.1/mkmf.rb:446:in
`try_compile'     from
/usr/local/lib/ruby/1.9.1/mkmf.rb:568:in
`try_var'     from
/usr/local/lib/ruby/1.9.1/mkmf.rb:816:in
`block in have_var'   from
/usr/local/lib/ruby/1.9.1/mkmf.rb:693:in
`block in checking_for'   from
/usr/local/lib/ruby/1.9.1/mkmf.rb:280:in
`block (2 levels) in postpone'    from
/usr/local/lib/ruby/1.9.1/mkmf.rb:254:in
`open'    from
/usr/local/lib/ruby/1.9.1/mkmf.rb:280:in
`block in postpone'   from
/usr/local/lib/ruby/1.9.1/mkmf.rb:254:in
`open'    from
/usr/local/lib/ruby/1.9.1/mkmf.rb:276:in
`postpone'    from
/usr/local/lib/ruby/1.9.1/mkmf.rb:692:in
`checking_for'    from
/usr/local/lib/ruby/1.9.1/mkmf.rb:815:in
`have_var'    from extconf.rb:16:in
`<main>'


Gem files will remain installed in
/usr/local/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10
for inspection. Results logged to
/usr/local/lib/ruby/gems/1.9.1/gems/eventmachine-0.12.10/ext/gem_make.out

在构建 C 扩展时,它似乎中断了。我尝试了各种解决方案,例如“ Mac OS X Leopard 安装 ruby​​ gem eventmachine ”,但没有运气。

4

4 回答 4

1

您需要安装 XCode 3.2 或 4 才能编译这样的扩展。XCode 包是可选安装,它可以在操作系统零售包的主安装 DVD 中提供,也可以作为新系统的补充光盘提供。

您可以从 App Store 下载 10.7 或更高版本。

于 2011-06-07T20:18:04.490 回答
0

我有同样的问题。打开mkmf.log文件并运行命令将问题缩小到 gmp 库。gmp 库位于不同的目录中并且LD_LIBRARY_PATH未设置。

我设置LD_LIBRARY_PATH为 gmp 所在的位置,然后正确安装。

于 2014-08-21T17:26:03.627 回答
0

您的问题可能是因为您没有安装 Xcode 4.2/4.3 的开发者工具。

对于 Xcode 4.2.x 和 4.3.x,您需要通过以下方式分别安装命令行工具:

  1. 启动 Xcode,然后从菜单栏上的“Xcode”菜单打开“Preferences”菜单。
  2. 选择“下载”选项卡(图标)。
  3. 单击“命令行工具”的“安装”按钮。

如果安装正确,那么运行cc --version应该输出:

% cc --version

    Apple clang version 3.1 (tags/Apple/clang-318.0.54) (based on LLVM 3.1svn)
    Target: x86_64-apple-darwin11.3.0
    Thread model: posix

或者,如果您使用的是 Ruby 1.9.3,则 EventMachine 存在已知问题。请参阅http://isitruby19.com/eventmachine。对于需要使用 RVM 或 rbenv 的 EventMachine 的项目,我建议您降级到 1.9.2。

于 2012-04-07T19:17:01.850 回答
0

这里的解决方案对我有用。我只需要从https://developer.apple.com/downloads/index.action安装命令行工具

有关更多信息,请参阅“使用 xcode 4.5.1 在 OSX Lion 10.8.2 上编译 eventmachine gem ”。

于 2013-06-23T14:49:16.383 回答