使用xcode 4.5.1在OSX Lion 10.8.2上编译eventmachine gem

我看到了我能找到的所有地方,但似乎无法找到解决方案。 我在Lion 10.8.2上使用xcode 4.5.1 – 我正在尝试为一个rails项目运行bundle而且它一直在干扰它。 我正在使用gem’瘦’用于heroku。 现在我不得不做 – 没有人找到解决方案?

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 

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

另外我遇到麻烦的MacOSX10.6.sdk因为那里丢失了一些标题,所以我安装了MacOSX10.5.sdk并且一切正常。

还要检查符号链接:

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

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

在我的设置中,我指出了Cellar中的位置:/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2

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

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

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

你应该有两个:

1) Xcode命令行工具 。 详细的安装说明在这里 。

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

 port select --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原生扩展时出现的错误问题

我决定删除我的应用程序并从git重新开始并且它有效 – 从来没有发现一个应用程序不起作用。