macos - gcc 不工作 - Xcode 3.2.6 - 雪豹

标签 macos gcc osx-snow-leopard rvm xcode3.2

我在乱搞我的环境方面有点新手,我似乎已经打破了它。非常感谢您提供的任何帮助。

主要症状是在尝试运行 rvm install 1.9.3 时我得到以下跟踪:

Installing Ruby from source to: /Users/duncanstuart/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...

ruby-1.9.3-p0 - #fetching 
ruby-1.9.3-p0 - #extracted to /Users/duncanstuart/.rvm/src/ruby-1.9.3-p0 (already extracted)
Fetching yaml-0.1.4.tar.gz to /Users/duncanstuart/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/duncanstuart/.rvm/src
Configuring yaml in /Users/duncanstuart/.rvm/src/yaml-0.1.4.
ERROR: Error running ' ./configure --prefix="/Users/duncanstuart/.rvm/usr"  ', please read /Users/duncanstuart/.rvm/log/ruby-1.9.3-p0/yaml/configure.log
Compiling yaml in /Users/duncanstuart/.rvm/src/yaml-0.1.4.
ERROR: Error running 'make ', please read /Users/duncanstuart/.rvm/log/ruby-1.9.3-p0/yaml/make.log
Installing yaml to /Users/duncanstuart/.rvm/usr
ERROR: Error running 'make install', please read /Users/duncanstuart/.rvm/log/ruby-1.9.3-p0/yaml/make.install.log
ruby-1.9.3-p0 - #configuring 
ERROR: Error running ' ./configure --prefix=/Users/duncanstuart/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/duncanstuart/.rvm/usr ', please read /Users/duncanstuart/.rvm/log/ruby-1.9.3-p0/configure.log
ERROR: There has been an error while running configure. Halting the installation.
yaml/configure.log的内容如下:
[2012-01-04 02:06:11]  ./configure --prefix="/Users/duncanstuart/.rvm/usr"  
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
configure: error: in `/Users/duncanstuart/.rvm/src/yaml-0.1.4':
configure: error: C compiler cannot create executables
See `config.log' for more details

我怀疑关键是:
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
yaml/make.log的内容和 yaml/make.install.log是相同的(当然除了前几行)
config.log的内容文件包含在这个问题的末尾(因为它很长!)。重要的一行似乎是:
`ld: library not found for -lcrt1.10.6.o`

我在运行 rvm install ... 时遇到同样的错误使用任何其他版本的 ruby​​,或者尝试使用 Homebrew 安装某些东西时,例如brew install wget
我的理论

我怀疑这与错误地卸载和重新安装 Xcode 3.2.6 有关 - 请参阅下面的历史了解我所做的全部细节。

我看过大量的stackoverflow帖子,但似乎没有人回答这个问题:
  • Can't install Ruby under Lion with RVM – GCC issues最接近我的问题,但最终似乎与 Xcode 4
  • 有关
  • Error installing Ruby with RVM作者实际上没有 c 编译器。 Problems installing Ruby with RVM: rvm install 1.8.7, rvm install 1.9.2大概是一样的。
  • Make error installing Ruby 1.9.2 via rvm OSX Lion 10.7.2 XCode 4.2类似但在 yaml/configure.log 中有不同的错误

  • 我的设置
  • 我正在运行雪豹 10.6.8
  • 我尝试在 1 月 3 日安装 Xcode 3.2.6,我认为它成功了
  • 我有 rvm 1.10.0(撰写本文时的最新版本)
  • 以下几行在 /usr/local/bin :
    lrwxr-xr-x   1 root       7  3 Jan 02:42 /usr/bin/gcc -> gcc-4.0
    -rwxr-xr-x   1 root   93072 23 Sep  2007 /usr/bin/gcc-4.0
    -rwxr-xr-x   1 root  166128 24 Oct  2010 /usr/bin/gcc-4.2
    

  • 如果您的建议是“升级到 Lion 并安装最新的 Xcode”,那么就这样吧。

    历史

    以下是我遵循的步骤: 我不确定什么是相关的,所以我将全部列出。
  • 我有一个 rvm 的工作实例 它能够成功安装所有 ruby​​ 1.9.2。我相信我使用的是 Xcode 3.2.6
  • 我有 macports 安装 - 我不记得为什么。
  • 我最近安装了 自制 出于某种原因或其他
  • 尝试运行时 rvm install 1.9.3我收到一个错误,我认为与此类似:
    openssl_missing.h:173: error: conflicting types for ‘BN_rand_range’
    /usr/local/Cellar/openssl/0.9.8r/include/openssl/bn.h:411: error: previous declaration of ‘BN_rand_range’ was here
    openssl_missing.h:177: error: conflicting types for ‘BN_pseudo_rand_range’
    /usr/local/Cellar/openssl/0.9.8r/include/openssl/bn.h:412: error: previous declaration of ‘BN_pseudo_rand_range’ was here
    openssl_missing.c:270: error: conflicting types for ‘BN_rand_range’
    /usr/local/Cellar/openssl/0.9.8r/include/openssl/bn.h:411: error: previous declaration of ‘BN_rand_range’ was here
    openssl_missing.c:278: error: conflicting types for ‘BN_pseudo_rand_range’
    /usr/local/Cellar/openssl/0.9.8r/include/openssl/bn.h:412: error: previous declaration of ‘BN_pseudo_rand_range’ was here
    
  • 谷歌搜索表明这是某种冲突,即机器上的 openssl 有两个定义(据我所知)。
  • 记住 Homebrew 有关于冲突的警告
    使用 MacPorts,我尝试 卸载 MacPorts 使用 instructions on the Macports Wiki .
    我还删除了大量与 MacPorts 相关的行
    .bash_profile
  • 那没有用,因为我根本不明白我在做什么,我 已卸载 Xcode sudo <Xcode>/Library/uninstall-devtools --mode=all .
  • 这当然让事情变得更糟并导致上面显示的错误。我因此重新安装 Xcode 来自原始 CD - 结果是 Xcode 3.0 .
  • 那并没有消除这些错误,所以我尝试 卸载该版本的 Xcode - 不幸的是,这需要手动更改卸载脚本中的系统版本,如 here 所述
  • 最后我下载并已安装 Xcode 3.2.6 (可用于 Snow Leopard 的最新 Xcode?)并且已经没有想法了。

  • 配置日志

    这是 config.log 文件的内容 - 在 /Users/duncanstuart/.rvm/src/yaml-0.1.4/ 中找到
    This file contains any messages produced by compilers while
    running configure, to aid debugging if configure makes a mistake.
    
    It was created by yaml configure 0.1.4, which was
    generated by GNU Autoconf 2.67.  Invocation command line was
    
      $ ./configure --prefix=/Users/duncanstuart/.rvm/usr CC=/usr/bin/gcc-4.2 --no-create --no-recursion
    
    ## --------- ##
    ## Platform. ##
    ## --------- ##
    
    hostname = duncan-stuarts-macbook.local
    uname -m = i386
    uname -r = 10.8.0
    uname -s = Darwin
    uname -v = Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
    
    /usr/bin/uname -p = i386
    /bin/uname -X     = unknown
    
    /bin/arch              = unknown
    /usr/bin/arch -k       = unknown
    /usr/convex/getsysinfo = unknown
    /usr/bin/hostinfo      = Mach kernel version:
         Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
    Kernel configured for up to 2 processors.
    2 processors are physically available.
    2 processors are logically available.
    Processor type: i486 (Intel 80486)
    Processors active: 0 1
    Primary memory available: 3.00 gigabytes
    Default processor set: 95 tasks, 425 threads, 2 processors
    Load average: 0.87, Mach factor: 1.12
    /bin/machine           = unknown
    /usr/bin/oslevel       = unknown
    /bin/universe          = unknown
    
    PATH: /Users/duncanstuart/.rvm/usr/bin
    PATH: /usr/local/bin
    PATH: /usr/local/sbin
    PATH: /usr/local/mysql/bin
    PATH: /bin
    PATH: /usr/sbin
    PATH: /sbin
    PATH: /usr/local/git/bin
    PATH: /usr/X11/bin
    PATH: /Users/duncanstuart/.rvm/bin
    PATH: /usr/bin
    
    
    ## ----------- ##
    ## Core tests. ##
    ## ----------- ##
    
    configure:2409: checking for a BSD-compatible install
    configure:2477: result: /usr/bin/install -c
    configure:2488: checking whether build environment is sane
    configure:2538: result: yes
    configure:2679: checking for a thread-safe mkdir -p
    configure:2718: result: config/install-sh -c -d
    configure:2731: checking for gawk
    configure:2761: result: no
    configure:2731: checking for mawk
    configure:2761: result: no
    configure:2731: checking for nawk
    configure:2761: result: no
    configure:2731: checking for awk
    configure:2747: found /usr/bin/awk
    configure:2758: result: awk
    configure:2769: checking whether make sets $(MAKE)
    configure:2791: result: yes
    configure:2947: checking for gcc
    configure:2974: result: /usr/bin/gcc-4.2
    configure:3203: checking for C compiler version
    configure:3212: /usr/bin/gcc-4.2 --version >&5
    i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    configure:3223: $? = 0
    configure:3212: /usr/bin/gcc-4.2 -v >&5
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
    configure:3223: $? = 0
    configure:3212: /usr/bin/gcc-4.2 -V >&5
    gcc-4.2: argument to `-V' is missing
    configure:3223: $? = 1
    configure:3212: /usr/bin/gcc-4.2 -qversion >&5
    i686-apple-darwin10-gcc-4.2.1: no input files
    configure:3223: $? = 1
    configure:3243: checking whether the C compiler works
    configure:3265: /usr/bin/gcc-4.2    conftest.c  >&5
    ld: library not found for -lcrt1.10.6.o
    collect2: ld returned 1 exit status
    configure:3269: $? = 1
    configure:3307: result: no
    configure: failed program was:
    | /* confdefs.h */
    | #define PACKAGE_NAME "yaml"
    | #define PACKAGE_TARNAME "yaml"
    | #define PACKAGE_VERSION "0.1.4"
    | #define PACKAGE_STRING "yaml 0.1.4"
    | #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component=libyaml"
    | #define PACKAGE_URL ""
    | #define PACKAGE "yaml"
    | #define VERSION "0.1.4"
    | #define YAML_VERSION_MAJOR 0
    | #define YAML_VERSION_MINOR 1
    | #define YAML_VERSION_PATCH 4
    | #define YAML_VERSION_STRING "0.1.4"
    | /* end confdefs.h.  */
    | 
    | int
    | main ()
    | {
    | 
    |   ;
    |   return 0;
    | }
    configure:3312: error: in `/Users/duncanstuart/.rvm/src/yaml-0.1.4':
    configure:3314: error: C compiler cannot create executables
    See `config.log' for more details
    
    ## ---------------- ##
    ## Cache variables. ##
    ## ---------------- ##
    
    ac_cv_env_CC_set=set
    ac_cv_env_CC_value=/usr/bin/gcc-4.2
    ac_cv_env_CFLAGS_set=
    ac_cv_env_CFLAGS_value=
    ac_cv_env_CPPFLAGS_set=
    ac_cv_env_CPPFLAGS_value=
    ac_cv_env_CPP_set=
    ac_cv_env_CPP_value=
    ac_cv_env_LDFLAGS_set=
    ac_cv_env_LDFLAGS_value=
    ac_cv_env_LIBS_set=
    ac_cv_env_LIBS_value=
    ac_cv_env_build_alias_set=
    ac_cv_env_build_alias_value=
    ac_cv_env_host_alias_set=
    ac_cv_env_host_alias_value=
    ac_cv_env_target_alias_set=
    ac_cv_env_target_alias_value=
    ac_cv_path_install='/usr/bin/install -c'
    ac_cv_prog_AWK=awk
    ac_cv_prog_ac_ct_CC=/usr/bin/gcc-4.2
    ac_cv_prog_make_make_set=yes
    
    ## ----------------- ##
    ## Output variables. ##
    ## ----------------- ##
    
    ACLOCAL='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/missing --run aclocal-1.11'
    AMDEPBACKSLASH=''
    AMDEP_FALSE=''
    AMDEP_TRUE=''
    AMTAR='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/missing --run tar'
    AR=''
    AUTOCONF='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/missing --run autoconf'
    AUTOHEADER='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/missing --run autoheader'
    AUTOMAKE='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/missing --run automake-1.11'
    AWK='awk'
    CC='/usr/bin/gcc-4.2'
    CCDEPMODE=''
    CFLAGS=''
    CPP=''
    CPPFLAGS=''
    CYGPATH_W='echo'
    DEFS=''
    DEPDIR=''
    DOXYGEN=''
    DOXYGEN_FALSE=''
    DOXYGEN_TRUE=''
    DSYMUTIL=''
    DUMPBIN=''
    ECHO_C='\c'
    ECHO_N=''
    ECHO_T=''
    EGREP=''
    EXEEXT=''
    FGREP=''
    GREP=''
    INSTALL_DATA='${INSTALL} -m 644'
    INSTALL_PROGRAM='${INSTALL}'
    INSTALL_SCRIPT='${INSTALL}'
    INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
    LD=''
    LDFLAGS=''
    LIBOBJS=''
    LIBS=''
    LIBTOOL=''
    LIPO=''
    LN_S=''
    LTLIBOBJS=''
    MAKEINFO='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/missing --run makeinfo'
    MKDIR_P='config/install-sh -c -d'
    NM=''
    NMEDIT=''
    OBJDUMP=''
    OBJEXT=''
    OTOOL64=''
    OTOOL=''
    PACKAGE='yaml'
    PACKAGE_BUGREPORT='http://pyyaml.org/newticket?component=libyaml'
    PACKAGE_NAME='yaml'
    PACKAGE_STRING='yaml 0.1.4'
    PACKAGE_TARNAME='yaml'
    PACKAGE_URL=''
    PACKAGE_VERSION='0.1.4'
    PATH_SEPARATOR=':'
    RANLIB=''
    SED=''
    SET_MAKE=''
    SHELL='/bin/sh'
    STRIP=''
    VERSION='0.1.4'
    YAML_LT_AGE='0'
    YAML_LT_CURRENT='2'
    YAML_LT_RELEASE='0'
    YAML_LT_REVISION='2'
    ac_ct_CC='/usr/bin/gcc-4.2'
    ac_ct_DUMPBIN=''
    am__EXEEXT_FALSE=''
    am__EXEEXT_TRUE=''
    am__fastdepCC_FALSE=''
    am__fastdepCC_TRUE=''
    am__include=''
    am__isrc=''
    am__leading_dot='.'
    am__quote=''
    am__tar='${AMTAR} chof - "$$tardir"'
    am__untar='${AMTAR} xf -'
    bindir='${exec_prefix}/bin'
    build=''
    build_alias=''
    build_cpu=''
    build_os=''
    build_vendor=''
    datadir='${datarootdir}'
    datarootdir='${prefix}/share'
    docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
    dvidir='${docdir}'
    exec_prefix='NONE'
    host=''
    host_alias=''
    host_cpu=''
    host_os=''
    host_vendor=''
    htmldir='${docdir}'
    includedir='${prefix}/include'
    infodir='${datarootdir}/info'
    install_sh='${SHELL} /Users/duncanstuart/.rvm/src/yaml-0.1.4/config/install-sh'
    libdir='${exec_prefix}/lib'
    libexecdir='${exec_prefix}/libexec'
    localedir='${datarootdir}/locale'
    localstatedir='${prefix}/var'
    lt_ECHO='/bin/echo'
    mandir='${datarootdir}/man'
    mkdir_p='$(top_builddir)/config/install-sh -c -d'
    oldincludedir='/usr/include'
    pdfdir='${docdir}'
    prefix='/Users/duncanstuart/.rvm/usr'
    program_transform_name='s,x,x,'
    psdir='${docdir}'
    sbindir='${exec_prefix}/sbin'
    sharedstatedir='${prefix}/com'
    sysconfdir='${prefix}/etc'
    target_alias=''
    
    ## ----------- ##
    ## confdefs.h. ##
    ## ----------- ##
    
    /* confdefs.h */
    #define PACKAGE_NAME "yaml"
    #define PACKAGE_TARNAME "yaml"
    #define PACKAGE_VERSION "0.1.4"
    #define PACKAGE_STRING "yaml 0.1.4"
    #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component=libyaml"
    #define PACKAGE_URL ""
    #define PACKAGE "yaml"
    #define VERSION "0.1.4"
    #define YAML_VERSION_MAJOR 0
    #define YAML_VERSION_MINOR 1
    #define YAML_VERSION_PATCH 4
    #define YAML_VERSION_STRING "0.1.4"
    
    configure: exit 77
    

    最佳答案

    最终结果证明这相当简单 - 非常感谢评论中帮助解决问题的每个人。

    有两个问题:

    问题 1:gcc 编译器不工作

    症状:

    依赖于 gcc 的函数在配置日志中失败并显示以下内容(例如 /Users/<user>/.rvm/log/ruby-1.9.3-p0/yaml/configure.log ):

    checking for gcc... /usr/bin/gcc-4.2
    checking whether the C compiler works... no
    

    ...以及配置日志中的以下内容(例如 /Users/<user>/.rvm/src/yaml-0.1.4/config.log ):
    ld: library not found for -lcrt1.10.6.o
    

    根本问题:

    Xcode 未正确安装。特别是文件 /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o不存在。

    解决方案:

    http://trac.macports.org/ticket/21784 :“尝试重新安装 Xcode,确保您选择了“unix 开发支持”选项。”

    问题 2:RVM 不会安装 ruby​​ 1.9.3

    症状:
    rvm install ruby 1.9.3失败 ERROR: Error running 'make '
    对应的/Users/<user>/.rvm/log/ruby-1.9.3-p0/make.log包含以下部分:
    compiling openssl_missing.c
    In file included from openssl_missing.c:22:
    openssl_missing.h:173: error: conflicting types for ‘BN_rand_range’
    /usr/include/openssl/bn.h:411: error: previous declaration of ‘BN_rand_range’ was here
    openssl_missing.h:177: error: conflicting types for ‘BN_pseudo_rand_range’
    /usr/include/openssl/bn.h:412: error: previous declaration of ‘BN_pseudo_rand_range’ was here
    openssl_missing.c:270: error: conflicting types for ‘BN_rand_range’
    /usr/include/openssl/bn.h:411: error: previous declaration of ‘BN_rand_range’ was here
    openssl_missing.c:278: error: conflicting types for ‘BN_pseudo_rand_range’
    /usr/include/openssl/bn.h:412: error: previous declaration of ‘BN_pseudo_rand_range’ was here
    

    根本问题:

    与之前运行的安装冲突(对此不完全确定)。

    解决方案

    https://rvm.beginrescueend.com/packages/openssl/ :清除您尝试安装并重新安装的 ruby​​:
    rvm remove 1.9.3
    rvm install 1.9.3
    

    我还删除了另外两个 ruby - ruby​​-1.9.2-p290 和 ruby​​-1.9.2-p136,这可能与它有关...:

    关于macos - gcc 不工作 - Xcode 3.2.6 - 雪豹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8721383/

    相关文章:

    c++ - GLIBCXX_3.4.21 未在具有链接时间引用的文件 libstdc++.so.6 中定义

    macos - Mac Pro 64 位寻址内核

    macos - Mac - 无法安装 Homebrew

    macos - 隐藏菜单栏并与applescript全局停靠

    c - 该函数是否被视为内联?

    python - 当我尝试为现有的 Pylons 应用提供服务时出现 PasteScript 错误

    objective-c - 如何生成序列号(注册号)?

    arrays - 如何在 xcode macos 中显示图像数组或网格中的任何对象数组

    objective-c - 用于大图像的 CIFilter inputIntensity slider

    c - 使用相同代码的 clang 和 gcc 之间的不同结果