无法使用RVM编译ruby 2.3.3

时间:2017-12-02 14:05:57

标签: ruby macos gcc rvm

我刚刚将OS X从我的旧MBP迁移到OS X High Sierra上运行的最新版本。 Ruby / RVM看起来很破碎。我尝试了以下内容:

  1. 重新安装XCode
  2. 重新安装命令行工具
  3. 重新安装RVM
  4. 重新安装自制程序
  5. 运行rvm install 2.3.3会产生以下结果:

    +__rvm_make:0> make -j 1
        CC = gcc
        LD = ld
        LDSHARED = gcc -dynamiclib
        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 -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens   -fno-common -pipe 
        XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
        CPPFLAGS = -I/usr/local/opt/openssl/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I. -I.ext/include/x86_64-darwin17 -I./include -I.
        DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -install_name /Users/rui/.rvm/rubies/ruby-2.3.3/lib/libruby.2.3.0.dylib -current_version 2.3.0 -compatibility_version 2.3.3  -fstack-protector -Wl,-u,_objc_msgSend -framework CoreFoundation  -fstack-protector -Wl,-u,_objc_msgSend -framework CoreFoundation  
        SOLIBS = -lpthread -ldl -lobjc 
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 9.0.0 (clang-900.0.38)
    Target: x86_64-apple-darwin17.2.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    translating probes probes.d
    . ./vm_opts.h
    compiling main.c
    In file included from main.c:13:
    In file included from ./include/ruby.h:33:
    ./include/ruby/ruby.h:1563:9: error: use of undeclared identifier 'LONG_MAX'
        if (RB_FIXABLE(v))
            ^
    ./include/ruby/ruby.h:385:24: note: expanded from macro 'RB_FIXABLE'
    #define RB_FIXABLE(f) (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f))
                           ^
    ./include/ruby/ruby.h:383:33: note: expanded from macro 'RB_POSFIXABLE'
    #define RB_POSFIXABLE(f) ((f) < RUBY_FIXNUM_MAX+1)
                                    ^
    ./include/ruby/ruby.h:251:26: note: expanded from macro 'RUBY_FIXNUM_MAX'
    #define RUBY_FIXNUM_MAX (LONG_MAX>>1)
                             ^
    ./include/ruby/ruby.h:1563:9: error: use of undeclared identifier 'LONG_MIN'
    ./include/ruby/ruby.h:385:44: note: expanded from macro 'RB_FIXABLE'
    #define RB_FIXABLE(f) (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f))
                                               ^
    ./include/ruby/ruby.h:384:34: note: expanded from macro 'RB_NEGFIXABLE'
    #define RB_NEGFIXABLE(f) ((f) >= RUBY_FIXNUM_MIN)
                                     ^
    ./include/ruby/ruby.h:252:38: note: expanded from macro 'RUBY_FIXNUM_MIN'
    #define RUBY_FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
                                         ^
    ./include/ruby/ruby.h:1573:9: error: use of undeclared identifier 'LONG_MAX'
        if (RB_POSFIXABLE(v))
            ^
    ./include/ruby/ruby.h:383:33: note: expanded from macro 'RB_POSFIXABLE'
    #define RB_POSFIXABLE(f) ((f) < RUBY_FIXNUM_MAX+1)
                                    ^
    ./include/ruby/ruby.h:251:26: note: expanded from macro 'RUBY_FIXNUM_MAX'
    #define RUBY_FIXNUM_MAX (LONG_MAX>>1)
                             ^
    In file included from main.c:13:
    In file included from ./include/ruby.h:33:
    In file included from ./include/ruby/ruby.h:1988:
    In file included from ./include/ruby/intern.h:35:
    ./include/ruby/st.h:85:30: error: use of undeclared identifier 'CHAR_BIT'
        st_index_t num_entries : ST_INDEX_BITS - 1;
                                 ^
    ./include/ruby/st.h:60:45: note: expanded from macro 'ST_INDEX_BITS'
    #define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT)
                                                ^
    4 errors generated.
    make: *** [main.o] Error 1
    +__rvm_make:0> return 2
    

1 个答案:

答案 0 :(得分:2)

事实证明,GCC正在查看标准标头的错误目录。解决方案与此处发布的解决方案相同:Broken c++ std libraries on macOS High Sierra 10.13