安装Python 2.6(Mac OS X Lion)时检查C编译器是否正常工作...失败。

4
我正在使用pyenv安装Python 2.6,但是在执行pyenv install 2.6.9时出现以下错误:

checking MACHDEP... darwin
checking EXTRAPLATDIR... $(PLATMACDIRS)
checking machine type as reported by uname -m... x86_64
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/var/folders/r9/771hsm9931sd81ppz31384p80000gn/T/python-build.20150213191018.2121/Python-2.6.9':
configure: error: C compiler cannot create executables

我已经安装了Xcode 4.6.3并安装了命令行工具。

谢谢,

Ch


显示 config.log 的内容。 - Ken Thomases
Autoconf的configure脚本会输出一个日志,其中包含运行过程中的详细信息,包括任何发生的错误。请检查该日志以查找哪个命令失败,并显示出现的错误消息。 - John Bollinger
这是我的配置文件的一部分:configure: gcc -V >&5 gcc: error: unrecognized option '-V' gcc: fatal error: no input files 还有 ld: library not found for -lgcc_ext.10.5 - ChrisB
完成以上操作:ld: 找不到库 -lgcc_ext.10.5 collect2: ld 返回 1 退出状态 configure:3436: $? = 1 configure:3474: 结果:否 configure: 失败的程序是: | /* confdefs.h */ | #define _GNU_SOURCE 1 | #define _NETBSD_SOURCE 1 | #define __BSD_VISIBLE 1 | #define _BSD_TYPES 1 | #define _DARWIN_C_SOURCE 1 | /* end confdefs.h. */ - ChrisB
1个回答

2

实际上,我找到了问题所在。问题出在ld: library not found for -lgcc_ext.10.5。 在Mac OS X Lion上,Xcode 4.6.3提供的gcc版本是4.6。

  1. 我通过homebrew安装了新的gcc,brew install gcc
  2. 我通过创建符号链接将我的gcc链接到gcc-4.9,执行命令:ln -s /usr/local/bin/gcc /usr/local/bin/gcc-4.9
  3. 确保在您的PATH路径中,/usr/local/bin/usr/bin之前)。
  4. 执行ls -l 'which gcc'来检查gcc是否与4.9版本相关联。完成此操作后,可以使用pyenv安装python 2.6。

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