gcc无法正常工作 - Xcode 3.2.6 - Snow Leopard

dgm*_*art 6 macos gcc osx-snow-leopard xcode3.2 rvm

我是一个搞乱我的环境的新手,我似乎相当破坏它.非常感谢您提供的任何帮助.

主要症状是,在尝试运行时,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.
Run Code Online (Sandbox Code Playgroud)

内容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
Run Code Online (Sandbox Code Playgroud)

我怀疑关键线是:

checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
Run Code Online (Sandbox Code Playgroud)

的内容yaml/make.logyaml/make.install.log是相同的(除了第一对过程的行)

config.log文件的内容包含在这个问题的最后(因为它很长!).重要的一行似乎是:

`ld: library not found for -lcrt1.10.6.o`
Run Code Online (Sandbox Code Playgroud)

rvm install ...与任何其他版本的ruby一起运行时,或者在尝试使用Homebrew安装某些内容时,我会遇到相同的错误brew install wget

我的理论

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

我已经看了很多stackoverflow帖子,但似乎没有人回答这个问题:

我的设置

  • 我正在运行Snow Leopard 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
    
    Run Code Online (Sandbox Code Playgroud)

如果您的建议是"升级到Lion并安装最新的Xcode",那就这样吧.

历史

以下是我遵循的步骤:我不确定什么是相关的,所以我会列出所有这些.

  1. 我有一个rvm工作实例,能够成功安装所有内容到ruby 1.9.2.我相信我使用的是Xcode 3.2.6
  2. 我安装了macports - 我不记得为什么.
  3. 我最近因某种原因安装了Homebrew
  4. 在尝试运行时,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
    
    Run Code Online (Sandbox Code Playgroud)
  5. 谷歌搜索周围表明,这是一种冲突,在机器上有两个openssl的定义(据我所知).

  6. 记住Homebrew有关于与MacPorts冲突的警告,我尝试使用Macports Wiki上的说明卸载MacPorts.我还从.bash_profile中删除了大量与MacPorts相关的行

  7. 这没有工作,因为我没有在所有我在做什么了解,我卸载的Xcodesudo <Xcode>/Library/uninstall-devtools --mode=all.

  8. 这当然使事情变得更糟并导致上面显示的错误.因此我从原始CD 重新安装了Xcode - 结果证明是Xcode 3.0.

  9. 所以我想这并没有消除这些错误卸载该版本的Xcode的 -不幸的是这需要手动更改在卸载脚本系统版本描述这里

  10. 最后,我下载并安装了Xcode 3.2.6(Snow Leopard最新的Xcode?)并且已经用完了想法.

的config.log

这是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
Run Code Online (Sandbox Code Playgroud)

dgm*_*art 6

事实证明这最终相当简单 - 非常感谢评论中的所有人帮助解决了这个问题.

有两个问题:

问题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
Run Code Online (Sandbox Code Playgroud)

...以及配置日志中的以下内容(例如/Users/<user>/.rvm/src/yaml-0.1.4/config.log):

ld: library not found for -lcrt1.10.6.o
Run Code Online (Sandbox Code Playgroud)

根问题:

Xcode未正确安装.具体来说,该文件/Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o不存在.

解:

http://trac.macports.org/ticket/21784:"尝试重新安装Xcode,确保选择"unix development support"选项."

问题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
Run Code Online (Sandbox Code Playgroud)

根问题:

与以前的安装运行冲突(不完全确定这一点).

https://rvm.beginrescueend.com/packages/openssl/:清理你要安装的ruby并重新安装:

rvm remove 1.9.3
rvm install 1.9.3
Run Code Online (Sandbox Code Playgroud)

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