运行configure命令时出现问题(检查C编译器是否正常工作...否)

时间:2012-08-18 02:02:53

标签: xcode macos unix gcc osx-lion

我正在尝试运行configure命令,但它会生成以下错误: 我正在运行Mountain Lion OS X 10.8

checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... i386-apple-darwin12.0.0
checking host system type... i386-apple-darwin12.0.0
checking target system type... i386-apple-darwin12.0.0
checking whether the C compiler works... no
configure: error: in `/Users/aditya15417/php-5.4.6':
configure: error: C compiler cannot create executables
See `config.log' for more details.

任何想法为什么会出现这个错误?我已经安装了Xcode命令行工具,我正在从终端运行configure命令。

我有XCode 4.4,我很确定已经安装了gcc,因为它给了我:

686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我尝试过:

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

但它不起作用。如果需要,这是指向config.log的链接。似乎从日志中找不到gcc4.2

configure:3524: checking for C compiler version
configure:3533: gcc-4.2 --version >&5
./configure: line 3535: gcc-4.2: command not found
configure:3544: $? = 127
configure:3533: gcc-4.2 -v >&5
./configure: line 3535: gcc-4.2: command not found
configure:3544: $? = 127
configure:3533: gcc-4.2 -V >&5
./configure: line 3535: gcc-4.2: command not found
configure:3544: $? = 127
configure:3533: gcc-4.2 -qversion >&5
./configure: line 3535: gcc-4.2: command not found
configure:3544: $? = 127
configure:3564: checking whether the C compiler works
configure:3586: gcc-4.2    conftest.c  >&5
./configure: line 3588: gcc-4.2: command not found
configure:3590: $? = 127
configure:3628: result: no

这怎么可能?

3 个答案:

答案 0 :(得分:2)

我刚刚编辑了.bash_profile,并注释掉了CC =行,因为我似乎认为它已经从之前的MacPorts安装中遗留下来了。

答案 1 :(得分:0)

从config.log文件中,它尝试使用不存在的编译器gcc-4.2。您需要告诉它使用确实存在的编译器,这通常通过设置环境变量CC

来完成

答案 2 :(得分:0)

我有一行:在我的.profile文件中导出CFLAGS =“ - arch ppc -arch x86_64 -g -O2 -m64”。删除-arch ppc后,我可以成功运行./configure。