0

我在 MacOS Lion(内核 v11.4.0)上使用 RVM v1.10.2、ruby v1.9.3p0 和 ruby​​ gems v1.8.15。

我使用 sinatra 为基于机架的项目创建了一个 gemset,并安装了一堆 gem,包括 eventmachine(由于安装了 thin)。没问题。

几周后,我为一个类似的项目创建了一个新的 gemset,但是当我尝试安装 Thin 时,一切都失败了。看起来编译 eventmachine 有问题。我尝试创建一个新的 gemset 并自行安装 eventmachine。没运气。我不知道为什么它曾经工作过,但现在失败了。


每当我gem install eventmachine,它是这样的:

Fetching: eventmachine-0.12.10.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing eventmachine:
        ERROR: Failed to build gem native extension.

        /Users/jared/.rvm/rubies/ruby-1.9.3-p0/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

然后它会在尝试编译各种文件时发出 bajillion 警告,最后是这个有趣的位:

linking shared-object rubyeventmachine.bundle
ld: warning: ignoring file /usr/local/lib/libz.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: in /usr/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rubyeventmachine.bundle] Error 1

这是完整的输出:https ://dl.dropbox.com/u/5382910/stackoverflow/gem_make.out


我安装其他 gem 没有问题,所以我怀疑这是编译器问题,但这里是 的输出gcc -v,以防有人发现某些东西:

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

任何帮助深表感谢!

4

2 回答 2

1

您正在使用 clang / LLVM 来构建 ruby​​ - 这只是实验性支持,您需要使用不基于 LLVM 的 gcc-4.2,这在 rvm 要求中描述得很好:

rvm get head     # get the latest update with the new requirements
rvm requirements # read carefully and follow instructions!
于 2012-07-26T20:43:39.160 回答
1

这一行是关键:

ld: in /usr/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64

这是输出中唯一不只是警告的内容。我不敢相信我忽略了它。这就是导致 clang 报告的原因error: linker command failed。在遇到以下问题后我意识到了这一点:Trouble Installation Ruby 1.9.2 with RVM Mac OS X

/usr/local/lib/libz.1.dylib只是一个符号链接/usr/local/lib/libz.1.2.5.dylib,根据文件上的日期,它是在我第一次安装 eventmachine 之后的某个时间创建的。所以,我刚刚删除/usr/local/lib/libz.1.dylib,我能够成功安装 eventmachine。我什至恢复到 LLVM gcc,它仍然有效。

于 2012-07-28T11:50:10.780 回答