Pyraf 在 os x 上构建错误版本的 gcc
Posted
技术标签:
【中文标题】Pyraf 在 os x 上构建错误版本的 gcc【英文标题】:Pyraf building wrong version of gcc on os x 【发布时间】:2012-03-01 01:20:49 【问题描述】:我已经通过 enthought 7.2 包安装了 python 2.7,我一直在尝试安装 pyraf 包,但是每次我尝试安装它时都会得到以下信息:
copying lib/pyraf/wutil.py -> build/lib.macosx-10.5-x86_64-2.7/pyraf
running build_ext
building 'pyraf.sscanfmodule' extension
creating build/temp.macosx-10.5-x86_64-2.7
creating build/temp.macosx-10.5-x86_64-2.7/src
gcc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -isysroot
/Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -O3 -arch x86_64 -isysroot
/Developer/SDKs/MacOSX10.5.sdk
-I/Library/Frameworks/EPD64.framework/Versions/7.1/include/python2.7
-I/usr/X11R6/include
-I/Library/Frameworks/EPD64.framework/Versions/7.1/include/python2.7 -c
src/sscanfmodule.c -o build/temp.macosx-10.5-x86_64-2.7/src/sscanfmodule.o
gcc: error: x86_64: No such file or directory
gcc: error: x86_64: No such file or directory
gcc: error: unrecognized option ‘-arch’
gcc: error: unrecognized option ‘-arch’
error: command 'gcc' failed with exit status 1
所以我认为这是一个架构问题,所以我重新安装了软件包(i386,XCode)然后得到了这个
running install
running build
running build_py
copying lib/pyraf/svn_version.py -> build/lib.macosx-10.5-i386-2.7/pyraf
running build_ext
building 'pyraf.sscanfmodule' extension
gcc -fno-strict-aliasing -fno-common -dynamic -arch i386 -isysroot
/Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -O3 -arch i386 -isysroot
/Developer/SDKs/MacOSX10.5.sdk -
I/Library/Frameworks/Python.framework/Versions/7.2/include/python2.7 -
I/usr/X11R6/include -
I/Library/Frameworks/Python.framework/Versions/7.2/include/python2.7 -c
src/sscanfmodule.c -o build/temp.macosx-10.5-i386-2.7/src/sscanfmodule.o
gcc: error: i386: No such file or directory
gcc: error: i386: No such file or directory
gcc: error: unrecognized option ‘-arch’
gcc: error: unrecognized option ‘-arch’
后来在我看来真正的问题是 gcc 版本问题,所以我寻找任何安装的 gcc,我发现了这个:
Last login: Wed Feb 29 11:06:40 on ttys009
Giotto:~ Huguito$ which gcc
/usr/local/bin/gcc
Giotto:~ Huguito$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin10.7.0/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10.7.0
Configured with: ../gcc-4.6.0/configure --enable-languages=fortran,c++
Thread model: posix
gcc version 4.6.0 (GCC)
gcc-4.2
alias gcc="/usr//bin/gcc-4.2"
Giotto:~ Huguito$ which gcc
/usr/local/bin/gcc
Giotto:~ Huguito$ gcc -v
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)
gcc-4.0:
alias gcc="/usr//bin/gcc-4.0"
Giotto:~ Huguito$ which gcc
/usr/local/bin/gcc
Giotto:~ Huguito$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc_40/gcc_40-5494~315/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-darwin10 --with-arch=apple --with-
tune=generic --host=i686-apple-darwin10 --target=i686-apple-darwin10
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5494)
所以我决定在我的 .bash_profile 文件中使用别名行指出正确的 gcc 版本,它根本不起作用。
我尝试设置 gcc 环境并构建 pyraf setup.py 并得到了这个:
Giotto:pyraf-dev Huguito$ export CC=/usr/bin/gcc-4.2
Giotto:pyraf-dev Huguito$ python setup.py build
running build
running build_py
copying lib/pyraf/svn_version.py -> build/lib.macosx-10.5-i386-2.7/pyraf
running build_ext
building 'pyraf.sscanfmodule' extension
/usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -arch i386 -isysroot
/Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -O3 -arch i386 -isysroot
/Developer/SDKs/MacOSX10.5.sdk -
I/Library/Frameworks/Python.framework/Versions/7.2/include/python2.7 -
I/usr/X11R6/include -
I/Library/Frameworks/Python.framework/Versions/7.2/include/python2.7 -c
src/sscanfmodule.c -o build/temp.macosx-10.5-i386-2.7/src/sscanfmodule.o
gcc -bundle -undefined dynamic_lookup -g -arch i386 build/temp.macosx-10.5-i386-
2.7/src/sscanfmodule.o -o build/lib.macosx-10.5-i386-2.7/pyraf/sscanfmodule.so
gcc: error: i386: No such file or directory
gcc: error: unrecognized option ‘-arch’
error: command 'gcc' failed with exit status 1
如果我键入 gcc 命令但没有 -arch i386 标志:
Giotto:pyraf-dev Huguito$ gcc -fno-strict-aliasing -fno-common -dynamic -isysroot
/Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -O3 -isysroot /Developer/SDKs/MacOSX10.5.sdk
-I/Library/Frameworks/Python.framework/Versions/7.2/include/python2.7 -
I/usr/X11R6/include -
I/Library/Frameworks/Python.framework/Versions/7.2/include/python2.7 -c
src/sscanfmodule.c -o build/temp.macosx-10.5-i386-2.7/src/sscanfmodule.o
它似乎编译得很好,但是在重新编译后它会忽略它并且根本不起作用。
【问题讨论】:
【参考方案1】:试试看。 从 Xcode 安装命令行工具。在 Xcode -> 首选项 -> 下载 -> 组件 -> 命令行工具
【讨论】:
以上是关于Pyraf 在 os x 上构建错误版本的 gcc的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Mac OS X 主机上为 MIPS 目标构建 GCC 4.8.x
MAC OS X 中 gcc 4.3 或更高版本的 OpenCV 编译错误
总线错误:Mac OS X 上带有 GCC 的内联 x86 程序集