15

I'm trying to install GDAL 1.7.1 on Mac OS X Lion using:

python setup.py build
python setup.py install

and get the error:

running build
running build_py
running build_ext
building 'osgeo._gdal' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -arch i386 -arch x86_64 -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Python/2.7/site-packages/numpy-2.0.0.dev_e2af7b7_20110721-py2.7-macosx-10.7-x86_64.egg/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.7/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-intel-2.7/extensions/gdal_wrap.o
unable to execute llvm-gcc-4.2: No such file or directory
error: command 'llvm-gcc-4.2' failed with exit status 1

Is this the right compiler? How can I get this working?

UPDATE:

I get a little further with Xcode installed:

running build
running build_py
running build_ext
building 'osgeo._gdal' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Python/2.7/site-packages/numpy-2.0.0.dev_e2af7b7_20110721-py2.7-macosx-10.7-x86_64.egg/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.7/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-intel-2.7/extensions/gdal_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
extensions/gdal_wrap.cpp:2813:22: error: cpl_port.h: No such file or directory
extensions/gdal_wrap.cpp:2814:24: error: cpl_string.h: No such file or directory
extensions/gdal_wrap.cpp:2815:27: error: cpl_multiproc.h: No such file or directory
extensions/gdal_wrap.cpp:2817:18: error: gdal.h: No such file or directory
extensions/gdal_wrap.cpp:2818:23: error: gdal_priv.h: No such file or directory
extensions/gdal_wrap.cpp:2819:22: error: gdal_alg.h: No such file or directory
extensions/gdal_wrap.cpp:2820:24: error: gdalwarper.h: No such file or directory
extensions/gdal_wrap.cpp:2837: error: expected initializer before ‘VeryQuietErrorHandler’
extensions/gdal_wrap.cpp:2713: warning: ‘swig_module’ defined but not used
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
extensions/gdal_wrap.cpp:2813:22: error: cpl_port.h: No such file or directory
extensions/gdal_wrap.cpp:2814:24: error: cpl_string.h: No such file or directory
extensions/gdal_wrap.cpp:2815:27: error: cpl_multiproc.h: No such file or directory
extensions/gdal_wrap.cpp:2817:18: error: gdal.h: No such file or directory
extensions/gdal_wrap.cpp:2818:23: error: gdal_priv.h: No such file or directory
extensions/gdal_wrap.cpp:2819:22: error: gdal_alg.h: No such file or directory
extensions/gdal_wrap.cpp:2820:24: error: gdalwarper.h: No such file or directory
extensions/gdal_wrap.cpp:2837: error: expected initializer before ‘VeryQuietErrorHandler’
extensions/gdal_wrap.cpp:2713: warning: ‘swig_module’ defined but not used
lipo: can't open input file: /var/tmp//ccgnLEPX.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1
Benjamin
  • 11,560
  • 13
  • 70
  • 119

5 Answers5

22

Homebrew works great for me. To install GDAL 1.9 with Homebrew all you have to do is

      brew install gdal

Homebrew requires xcode, and I think commandline tools. More information can be found here

foundatron
  • 351
  • 2
  • 9
  • yes... the whole "kyngchaos" thing makes me nervous and has ALWAYS been a hassle – Matthew Turner Oct 28 '14 at 22:02
  • ports as opposed to brew has the 2.0.1 version – Davoud Taghawi-Nejad Feb 10 '16 at 00:32
  • This should be the accepted answer I think. As the first commenter said, "kyngchaos" really isn't a useful guide when installing GDAL. Ports has made the installation process seamless. However I run into trouble that bash is still referencing the older version, and not the newer port version. – coffeepls Feb 18 '16 at 00:13
5

Did you actually install Xcode 4.1 on 10.7? Downloading it from the App Store is not enough; you have to manually run the Installer which it downloads to /Applications.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
5

How about using the precompiled binaries available from http://www.kyngchaos.com/software/frameworks

Also, are you using 1.7.1 for a specific reason? 1.8.1 is, I believe, the current release build.

Caveat: I do not know if Lion is yet supported by the GDAL OSX binaries.

Jzl5325
  • 3,898
  • 8
  • 42
  • 62
  • 2
    Precompiled binaries are not really a solution to problems building from source. – Benjamin Aug 27 '11 at 14:04
  • 1
    Absolutely true, but if your end goal is to use GDAL and the binaries exist why not use them. You can work on your compiling issues as well, but still have access to GDAL in the interim. Did you get this working? – Jzl5325 Sep 04 '11 at 00:30
  • I have NOT compiled GDAL from source, but have had loads of trouble trying to compile GEOS...to the point of bailing and using Shapely (a python library). can you comment out the GEOS build somehow? Also, have you seen http://bugs.python.org/issue5755. The link might help with cc1plus warning you are getting? I would start with GEOS though. I know that KyngChaos (the binary creator) dropped GEOS compilation due to issues... – Jzl5325 Sep 06 '11 at 17:45
  • kyngchaos does it again. Just had to wait for the new version. Installed GDAL complete 2011-9-17... – Benjamin Sep 23 '11 at 00:06
  • I can't get that same GDAL version to work. . . did you just double-click the package to install and you could then use it from Terminal? Or is there something extra I'm missing? Thanks! – Dylan Gattey Sep 29 '11 at 05:51
3

If you actually want to build from source, but want a convenient way to install there is a gdal package available from MacPorts - just install MacPorts, then on the command line type:

port install gdal

Macports will fetch and compile the source code for you. As of the time of writing the version in MacPorts is 1.9.0

jportway
  • 917
  • 8
  • 17
0

for installing GDAL on mac:

brew install gdal

and then

pip install gdal

solved this for me

Geoff Perrin
  • 444
  • 1
  • 6
  • 14