gcc not working - Xcode 3.2.6 - Snow Leopard
Asked Answered
M

1

6

I'm a bit of a novice at messing around with my environment and I seem to have rather broken it. Many thanks in advance for any assistance you can offer.

The main symptom is that when trying to run rvm install 1.9.3 I get the following trace:

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.

The contents of yaml/configure.log is as follows:

[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

I suspect the key lines are:

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

The contents of yaml/make.log and yaml/make.install.log are the same (except for the first couple of lines of course)

The contents of the config.log file are included at the end of this question (because it's very long!). The significant line seems to be:

`ld: library not found for -lcrt1.10.6.o`

I get the same errors when running rvm install ... with any other version of ruby, or when trying to install something with Homebrew e.g. brew install wget

My theory

I suspect this has got something to do with incorrectly uninstalling and reinstalling Xcode 3.2.6 - see History below for full details of what I've done.

I've had a look at a ton of stackoverflow posts, but none seem to answer this:

My Setup

  • I'm running Snow Leopard 10.6.8
  • I've tried to install Xcode 3.2.6 on 3rd Jan and I think it succeeded
  • I've got rvm 1.10.0 (the latest version at the time of writing)
  • The following lines are in /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
    

If your advice is "upgrade to Lion and install the latest Xcode" then so be it.

History

Here are the steps which I've followed: I'm not sure what's relevant so I'll list it all.

  1. I had a working instance of rvm which was able to successfully install everything up to ruby 1.9.2. I believe I was using Xcode 3.2.6
  2. I had macports installed - I can't remember why.
  3. I had more recently installed Homebrew for some reason or other
  4. When trying to run rvm install 1.9.3 I got an error which I believe was similar to this:

    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
    
  5. Googling around suggested that this was some sort of conflict whereby there were two definitions of openssl on the machine (as far as I could understand).

  6. Remembering that there was a warning from Homebrew about conflicts with MacPorts, I tried to uninstall MacPorts using the instructions on the Macports Wiki. I also removed a load of lines related to MacPorts from my .bash_profile

  7. That didn't work and because I didn't understand at all what I was doing, I uninstalled Xcode with sudo <Xcode>/Library/uninstall-devtools --mode=all.

  8. This of course made matters worse and lead to the errors shown above. I therefore reinstalled Xcode from the original CD - this turned out to be Xcode 3.0.

  9. That didn't remove those errors so I tried to uninstall that version of Xcode - unfortunately this requires manually changing the system versions in the uninstall scripts as described here

  10. Finally I downloaded and installed Xcode 3.2.6 (the most recent Xcode available for Snow Leopard?) and have run out of ideas.

config.log

This is the contents of the config.log file - found in /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
Murrey answered 4/1, 2012 at 2:36 Comment(14)
Remove the things that aren't missing from openssl_missing.h.Tweet
The OpenSSL conflicting types error is completely different from cannot create executables -- what happens if you run: echo "int main(int argc, char *argv[]) { return 0; }" > foo.c ; gcc-4.2 -o foo foo.c ; ./foo in your home directory or in /tmp ?Strongminded
@Strongminded I get the following: ld: library not found for -lcrt1.10.6.o collect2: ld returned 1 exit status bash: ./foo: No such file or directory All greek to me I'm afraidMurrey
@DavidSchwartz Thank you - where can I find openssl_missing.h? Or does this not apply right now because /usr/local/Cellar/openssl/ doesn't seem to exist anymore?Murrey
I believe that library not found for -lcrt1.10.6.o is the most critical error message you've gotten so far. I don't know OS X platform well enough to suggest the next step, but search from that starting point.Strongminded
do you have a /usr/lib/crt1.10.6.o?Delia
@MikeK Apparently not: however I do have crt1.10.5.o and crt1.o I have no idea what any of that means, but is it relevant that my OSX version is 10.6.8?Murrey
Sounds like these comments are focusing on the errors you were reaching in your history before this new issue which is entirely different. Yes, the fundamental problem now is that it can find a working GCC. What happens when you try running /usr/bin/gcc -v directly?Memling
@SpencerWysinger bash-3.2$ /usr/bin/gcc -v Using built-in specs. Target: i686-apple-darwin9 Configured with: /var/tmp/gcc/gcc-5465~16/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9 Thread model: posix gcc version 4.0.1 (Apple Inc. build 5465)Murrey
I'm so sorry, I meant try running gcc-4.2. That's what configure is trying to use from the looks of your output from before. However, if the other is working, try setting CC to it in your environment before running the install (export CC=/usr/bin/gcc).Memling
@Strongminded @MikeK @SpencerWysinger: I've found the config.log and added it above - it also contains the library not found for -lcrt1.10.6.oline.Murrey
@SpencerWysinger running just gcc-4.2 gives me i686-apple-darwin10-gcc-4.2.1: no input files Does that mean it's working? I've tried again with export CC=/usr/bin/gcc, .../gcc-4.2.1, .../gcc-4.2, .../gcc-4.0 but no difference. In all cases the config.log seems to show that configure is trying to use gcc-4.2 and giving the error library not found for -lcrt1.10.6.o.Murrey
@MikeK @sardnold ARG - slightly embarrassing - turned out Xcode hadn't installed properly. Tried it one more time and now I have /usr/lib/crt1.10.6.o Many thanks for educating me and helping me to get to this point!!Murrey
OMG - got it working. Thanks so much everyone. Will post a full solution below.Murrey
M
7

This turned out to be fairly simple in the end - many thanks to everyone in the comments who helped work it out.

There were two issues:

Issue 1: gcc compiler wasn't working

Symptoms:

Functions dependent on gcc fail with the following in the configure log (e.g./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

...and the following in the config log (e.g. /Users/<user>/.rvm/src/yaml-0.1.4/config.log):

ld: library not found for -lcrt1.10.6.o

Root issue:

Xcode hasn't been installed properly. Specifically the file /Developer/SDKs/MacOSX10.6.sdk/usr/lib/crt1.10.6.o doesn't exist.

Solution:

http://trac.macports.org/ticket/21784: "Try reinstalling Xcode, make sure you choose the "unix development support" option."

Issue 2: RVM wouldn't install ruby 1.9.3

Symptoms:

rvm install ruby 1.9.3 fails with ERROR: Error running 'make '

The corresponding /Users/<user>/.rvm/log/ruby-1.9.3-p0/make.log contains the following segment:

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

Root issue:

Conflicts with previous runs of the install (not entirely sure about this).

Solution

https://rvm.beginrescueend.com/packages/openssl/: clean out the ruby you are trying to install and reinstall:

rvm remove 1.9.3
rvm install 1.9.3

I also removed two other rubies - ruby-1.9.2-p290 and ruby-1.9.2-p136, which might have had something to do with it...:

Murrey answered 4/1, 2012 at 22:3 Comment(3)
Excellent write-up: two confounding issues definitely made this one harder to track down than usual -- and a half-installed Xcode that gives you GCC but not the C runtime support library hopefully doesn't happen often. :)Strongminded
It's so that I search this site before Google! Thank you so much!Babblement
If you want to avoid Xcode altogether, you can use osx-gcc-installer to get the libs, and then do CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --with-shared to install on Lion (probably Snow Leopard, too). It'll be compiled for 64-bit, which is nice.Mazer

© 2022 - 2024 — McMap. All rights reserved.