Search code examples
gcchomebrewgdal

Home brew failing on “command ‘gcc’ failed with exit status 1″ error


I want to get started with geodjango and for this I have to install gdal. I am using MacOS 10.8.3 In order to do so with brew as advised in the geodjango documentation but I get the following error :

$brew install gdal 
==> Downloading http://download.osgeo.org/gdal/1.10.0/gdal-1.10.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/gdal-1.10.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/gdal/1.10.0 --mandir=/usr/local/Cellar/gdal/1.10.0/share/man --with-local=/usr/local/Cellar/gdal/1.10.0 --with-threads --with-libtool -
==> make
==> make install
==> /Users/Lucas/.virtualenvs/geotest/bin/python setup.py install --prefix=/usr/local/Cellar/gdal/1.10.0 --record=installed.txt --single-version-externally-managed
gcc-4.2 -bundle -undefined dynamic_lookup -g -L/usr/local/opt/sqlite/lib -lsqlite3 -I/usr/local/opt/sqlite/include -arch x86_64 build/temp.macosx-10.6-intel-2.7/extensions/gdalconst_wrap.o -L../../.libs -L../../ -L/private/tmp/gdal-gOux/gdal-1.10.0/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_gdalconst.so
Your Xcode and or CLT are mis-configured. Try some or all of the following:
    xcodebuild -license
    sudo xcode-select -switch /path/to/Xcode.app
error: command 'gcc-4.2' failed with exit status 1
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/mxcl/homebrew/issues/19845
    https://github.com/mxcl/homebrew/issues/20373
    https://github.com/mxcl/homebrew/pull/20457

As advised, I did :

xcodebuild -license

and agreed to the licence, then :

sudo xcode-select -switch /Applications/Xcode.app

I also checked the issues but none of them was helpfull.

I have Xcode 4.6.3 installed and have brewed lots of other formulaes in the past without any problem.

When I run brew doctor, I get :

$brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

    /Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
    /Applications/Postgres.app/Contents/MacOS/bin/gdal-config
    /Applications/Postgres.app/Contents/MacOS/bin/geos-config
    /Applications/Postgres.app/Contents/MacOS/bin/uuid-config
    /Applications/Postgres.app/Contents/MacOS/bin/xml2-config

I don't want to remove postgres.app from my path as it is necessary for the CLI of postgres.app configuration as explained here : http://postgresapp.com/documentation#toc_1

About the python from library, I tried to remove them using :

PATH=$(echo $PATH |sed 's/\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin//')

as advised here :https://www.linuxquestions.org/questions/linux-newbie-8/how-to-remove-directory-from-%24path-483463/. But it did not removed anything from the path.

So here I am not installing gdal ...


Solution

  • I found a workaround on SO, I can't find the original post but similar info is given on this one : Installing Scipy on Mac OS X Lion 10.7.5

    So I added the following lines to my .bashrc and I then managed to brew install gdal.

    export CC=gcc
    export CXX=g++
    

    Be aware that this did not solved my problem entirely as I still have config issue with geodjango, but at least I have gdal installed.