【问题标题】:How to get the EventMachine gem to compile on OSX Lion 10.8.2 with Xcode 4.5.1如何使用 Xcode 4.5.1 在 OSX Lion 10.8.2 上编译 EventMachine gem
【发布时间】:2012-10-16 06:05:49
【问题描述】:

我到处寻找我能找到的地方,但似乎找不到解决办法。

我在 Lion 10.8.2 上使用 Xcode 4.5.1,并试图为 Rails 项目运行 bundle,但它一直在这个问题上卡住。我正在为 Heroku 使用 Thin gem。

Bolanos@Jeremys-Mac-mini ⦿-1.9.3 fishfarm $ sudo gem install eventmachine
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing eventmachine:
    ERROR: Failed to build gem native extension.

        /Users/Bolanos/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
creating Makefile

make
compiling binder.cpp
make: g++-4.2: No such file or directory
make: *** [binder.o] Error 1


Gem files will remain installed in /Users/Bolanos/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0 for inspection.
Results logged to /Users/Bolanos/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0/ext/gem_make.out

现在我不得不放弃 Thin。有人有解决办法吗?

【问题讨论】:

  • 你的 g++ 呢?你安装了 Xcode 的命令行工具了吗?
  • 是的,我安装了这些工具 - 它适用于我的所有其他应用程序,我可以创建一个新的并安装 Thin 并且它可以工作 - 它不适用于这个特定的应用程序。
  • 我决定删除我的应用程序并从 git 重新开始,它可以工作 - 从来没有想过一个应用程序不能工作。

标签: ruby-on-rails ruby heroku thin eventmachine


【解决方案1】:

同时检查符号链接:

$ sudo ln -s /usr/bin/g++ /usr/bin/g++-4.2

【讨论】:

  • 这对我来说似乎是正确的答案,因为错误是make: g++-4.2: No such file or directory
【解决方案2】:

您必须从developer.apple.com 安装命令行工具包。

另外我在使用 MacOSX10.6.sdk 时遇到了问题,因为那里缺少一些头文件,所以我安装了 MacOSX10.5.sdk,一切正常。

【讨论】:

    【解决方案3】:

    我遇到了确切的错误,为缺少的资源创建一个新的符号链接 /usr/bin/g++-4.2 对我有用。

    在我的设置中,我指向地窖中的位置:

    /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
    

    【讨论】:

      【解决方案4】:

      如果以上方法都不适合你,我做了

      sudo ln -s /usr/bin/llvm-g++-4.2 /usr/bin/g++-4.2
      

      它就像一个魅力。运行 OS X 10.8.2。

      【讨论】:

        【解决方案5】:

        你应该同时拥有:

        1. Xcode命令行工具:详细安装说明在“How to install Xcode Command Line Tools”。

        2. Apple-gcc* 编译器:我应该提到使用 gcc48 和 gcc49 编译失败。因此,安装 apple-gcc42(如果没有)并通过MacPorts 选择编译器将解决问题。您可以使用以下命令查看已安装的 gcc 版本:

          端口选择--list gcc

        您应该会看到类似这样的内容,其中“mp-”代表 MacPorts 自己的端口:

        Available versions for gcc:
                 apple-gcc42 (active)
                 current_saved
                 mp-gcc48
                 mp-gcc49
        

        如果您没有“apple-gcc*”,您可以通过以下方式安装它:

        port install apple-gcc42
        

        之后选择编译器:

        port select --set gcc apple-gcc42
        

        现在你可以运行了:

         gem install eventmachine
        

        这应该可以解决在 OSX 上构建 gem 原生扩展时出现的错误问题。

        【讨论】:

          猜你喜欢
          • 2012-12-16
          • 2012-12-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-02-10
          • 2012-05-07
          相关资源
          最近更新 更多