在OS X 10.9.2下使用Rbenv制作Ruby 2.1.1失败

GCC-4.9 Fails to Make Ruby 2.1.1 with Rbenv in OS X 10.9.2

本文关键字:制作 Rbenv Ruby 失败 OS 2下      更新时间:2023-10-16

我在这里超出了我的深度,因为我对C和这样的编译器不了解,除了根据tut的我已经读过-我已经自制安装了gcc-4.9,链接它,并在我的。bash_profile中有cc=gcc-4.9 -希望这将允许我安装Ruby 2.1.1,因为以前的尝试失败了,抱怨如下:

note: unrestricted unions only available with -std=c++11 or -std=gnu++11

我访问了gcc网站,看到4.9包含c++11支持,所以我很困惑,为什么它不能按照上面的错误制作Ruby,下面是完整的错误输出:

 make
CC = /usr/local/bin/g++-4.9
LD = ld
LDSHARED = /usr/local/bin/g++-4.9 -dynamic -bundle
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings   -pipe 
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -I/usr/local/Cellar/openssl/1.0.1g/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I. -I.ext/include/x86_64-darwin13.0 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/Cellar/openssl/1.0.1g/lib  -fstack-protector -Wl,-u,_objc_msgSend -pie -framework CoreFoundation  
SOLIBS = -lgmp 
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++-4.9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc49/4.9.0/libexec/gcc/x86_64-apple-darwin13.1.0/4.9.0/lto-wrapper
Target: x86_64-apple-darwin13.1.0
Configured with: ../configure --build=x86_64-apple-darwin13.1.0 --prefix=/usr/local/Cellar/gcc49/4.9.0 --enable-languages=c,c++,objc,obj-c++ --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08 --with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011 --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.0 (GCC) 
compiling miniprelude.c
In file included from vm_core.h:24:0,
             from miniprelude.c:8:
method.h:84:19: error: member 'rb_method_attr_t rb_method_definition_struct::<anonymous union>::attr' with copy assignment operator not allowed in union
rb_method_attr_t attr;
               ^
method.h:84:19: note: unrestricted unions only available with -std=c++11 or -std=gnu++11
In file included from miniprelude.c:8:0:
vm_core.h:674:59: error: use of enum 'iseq_type' without previous declaration
VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE, enum iseq_type);
                                                       ^
vm_core.h:677:76: error: use of enum 'iseq_type' without previous declaration
VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type,     VALUE);
                                                                        ^
vm_core.h:678:75: error: use of enum 'iseq_type' without previous declaration
VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, const rb_compile_option_t*);
                                                                       ^
make: *** [miniprelude.o] Error 1

正如我所写的,我真的不知道该怎么做了,所以如果有人能帮我解决这个问题,我就能安装Ruby 2.1.1了。

我使用的./configure命令是:

./configure --prefix="$HOME/.rbenv/versions/2.1.1" --with-opt-dir=/usr/local/Cellar/openssl/1.0.1g

我通过自制安装了Rbenv,所以它的bin不在~中。/rbenv,但在我的路径和系统链接的自制从:

/usr/local/bin/rbenv -> ../Cellar/rbenv/0.4.0/bin/rbenv

我看不到任何抱怨,这让我认为我可能使用错误的c编译器,但我没有看到其他人有同样的错误,他们很高兴与自制的gcc-4.9或apple-gcc42,但说实话-我不知道如何确定使用哪个。

感谢任何帮助,因为我已经浪费了太多的时间,而不是实际开发一个web应用程序。

谢谢

错误信息

 note: unrestricted unions only available with -std=c++11 or -std=gnu++11

表示只有当gcc(或g++)以选项-std=c++11-std=gnu++11启动时,某些特性才可用

因此,gcc 4.9包含对c++11的支持,但默认情况下不启用它。添加命令行选项-std=c++11以启用支持。这些选项通常包含在CFLAGS变量中。或者你甚至可以试着把它添加到你的抄送中。

我认为在Ruby的configure脚本可能有错误。这个脚本应该检查所有需要的特性,并为CFLAGS添加正确的标志,但在您的情况下,它未能将-std=c++11添加到标志中。