0

我在这里超出了我的深度,因为我不了解 Jack 关于 C 和此类编译器,除了根据 tut's 我读过 - 我已经自制安装了 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 中,而是在我的 PATH 和自制软件链接的 sym 中:

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

我看不到任何对此的抱怨,这让我觉得我可能使用了错误的 C 编译器,但我没有看到其他人有同样的错误,他们对自制的 gcc-4.9 或 apple-gcc42 很满意,但老实说 - 我不知道如何确定使用哪个。

任何帮助表示赞赏,因为我在这方面浪费了太长时间,而不是实际开发 Web 应用程序。

谢谢

4

1 回答 1

0

错误信息

 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变量中。或者您甚至可以尝试将其添加到您的 CC 中。

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

于 2014-05-05T00:38:42.750 回答