在Mac OS X Lion上安装GDAL

15

我正在尝试在Mac OS X Lion上安装GDAL 1.7.1,使用以下命令:

python setup.py build
python setup.py install

并且收到了以下错误:

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

这是正确的编译器吗?如何使它工作起来?

更新:

我安装了Xcode之后有一点进展:

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
5个回答

22

Homebrew对我来说效果很好。要使用Homebrew安装GDAL 1.9,你只需要执行以下操作:

      brew install gdal

Homebrew需要Xcode,以及我认为的命令行工具。更多信息可以在这里找到。


是的...整个“kyngchaos”的事情让我感到紧张,而且一直都很麻烦。 - Matthew Turner
端口与Brew相比,具有2.0.1版本。 - Davoud Taghawi-Nejad
我认为这应该是被接受的答案。正如第一位评论者所说,“kyngchaos”在安装GDAL时确实不是一个有用的指南。Ports使安装过程变得无缝。然而,我遇到了问题,即bash仍然引用旧版本而不是新的端口版本。 - coffeepls

5

你是否在10.7上实际安装了Xcode 4.1?仅从应用商店下载是不够的,你需要手动运行它下载到/Applications的安装程序。


看到我的修改,Xcode现在已经安装了,但这并没有解决问题。 - Benjamin

5

考虑使用从http://www.kyngchaos.com/software/frameworks获取的预编译二进制文件。

此外,您使用1.7.1是否有特定原因?我相信1.8.1是当前的发布版本。

注意:我不知道Lion是否受GDAL OSX二进制文件支持。


2
预编译二进制文件并不能真正解决从源代码构建的问题。 - Benjamin
1
绝对正确,但如果您的最终目标是使用GDAL并且二进制文件存在,为什么不使用它们呢?您也可以解决编译问题,但在此期间仍然可以访问GDAL。您已经解决了这个问题吗? - Jzl5325
我尚未从源代码编译GDAL,但是在尝试编译GEOS时遇到了很多麻烦...甚至放弃并使用了Shapely(一个Python库)。你能否以某种方式注释掉GEOS的构建?此外,您是否看过http://bugs.python.org/issue5755。该链接可能有助于解决您正在收到的cc1plus警告?我会从GEOS开始。我知道二进制创建者KyngChaos由于问题而放弃了GEOS编译。 - Jzl5325
kyngchaos 再次做到了。只需要等待新版本。已安装 GDAL complete 2011-9-17... - Benjamin
我无法让相同版本的GDAL工作。你只是双击安装包进行安装,然后就可以从终端使用它了吗?还是我漏掉了什么额外的东西?谢谢! - Dylan Gattey

3

如果您想从源代码构建,但希望有一个方便的安装方式,可以使用MacPorts提供的gdal软件包 - 只需安装MacPorts,然后在命令行上输入:

port install gdal

Macports 会为您获取并编译源代码。截至本文撰写时,MacPorts 的版本为1.9.0。


如果可以的话,我会给+10分。Brew已经对我有些不满了。 - timop
端口与Brew相比,具有2.0.1版本。 - Davoud Taghawi-Nejad
很好。应该是“端口”而不是“端口们”。 - Allan Guwatudde

0

在Mac上安装GDAL:

brew install gdal

然后执行:

pip install gdal

这样就解决了我的问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接