虽然cc
并且gcc
完全处于正确的路径(/Developer/usr/bin
在 OS X Lion 中),但运行./configure
尝试通过硬编码(我猜)路径来编译它 - /usr/bin
.
我在哪里设置配置的路径?
正确的答案是从 App Store(免费)安装 Xcode 4,然后运行 /Applications/Install Xcode.app。然后你需要的一切都在 /usr/ 中。
最好的办法实际上是从 Apple 下载并安装新的命令行开发人员工具包,它在 /usr/bin 中为您提供工具以及在适当位置的库和文档(例如联机帮助页)。要么在 developer.apple.com 上找到它,要么在此处查看详细信息和链接。
I just ran into this... I "solved" it by just installing the XCode "Command Line Tools" package
But for some reason it is not possible (for me at least) to reach the same preferences window when a project is open. I had to do the following
,
Downloads
install
njamesp 是正确的;解决问题的正确方法是正确安装编译器工具链。但是对于我在哪里设置配置路径的问题?,有几个解决方案。
将其传递给配置为命令行选项:/path/to/configure CC=/p/a/t/h
(不推荐使用的 bourne shell)在环境中传递它:CC=/p/a/t/h /p/t/configure
(已弃用-csh)env CC=/p/a/t/h /p/t/configure
设置一个 config.site。放入CONFIG_SITE
您的环境中作为文件的路径,(例如 export CONFIG_SITE=$HOME/config.site
),放入CC=/p/a/t/h
该文件
放入CC=/p/a/t/h
_/usr/local/share/config.site
所有这些都假设您的配置脚本是由 autoconf 生成的。不鼓励使用选项 2 和 3,但如果您的配置脚本是古老的,选项 1 可能不起作用。选项 5 很灵活,您可以根据前缀使用不同的 config.sites。$prefix/share/config.site 可用于为安装在$prefix
.
第 1 项正确:我只是做了同样的事情。
安装 XCODE 启动 XCODE 单击 Xcode 选择首选项 单击 XCode 首选项窗格中的下载 单击命令行工具并单击“安装”
编译器安装在 /usr/bin
cd 在那里,然后输入"gcc -v"
(不带引号),你应该得到以下内容:
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
$
我最近安装了 OSX Mavericks 并想升级到 php 5.5.5 并遇到了类似的问题
[user@host /path/to/php5.5.5_src]$ ./configure
checking for cc... cc
checking whether the C compiler works... no
查看我的包含路径,我注意到只添加了基本 Xcode 路径(我有 Xcode 5)
[user@host ~]$ cat /etc/paths
/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin
/bin
...
我需要做的就是添加工具链的路径
[user@host ~]$ sudo vi /etc/paths
/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
/bin
...
瞧,它找到了。
[user@host /path/to/php5.5.5_src]$ ./configure
checking for cc... cc
checking whether the C compiler works... yes
希望这可以帮助。