xcode ./configure 在 OS X Lion 安装后找不到 C 编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6793823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:02:41  来源:igfitidea点击:

./configure can't find C compiler after OS X Lion installation

xcodemacososx-lionconfigure

提问by Tomer Lichtash

While ccand gccare perfectly in their right path (/Developer/usr/binin OS X Lion), running ./configuretries to compile it through a hard coded (I guess) path - /usr/bin.

虽然cc并且gcc完全在他们的正确路径上(/Developer/usr/bin在 OS X Lion 中),运行./configure尝试通过硬编码(我猜)路径编译它 - /usr/bin.

Where do I setup configure's paths?

我在哪里设置配置的路径?

回答by njamesp

The right answer is to install Xcode 4 from the App Store (free) and then run /Applications/Install Xcode.app. Then everything you need will be in /usr/.

正确的答案是从 App Store(免费)安装 Xcode 4,然后运行 ​​/Applications/Install Xcode.app。然后你需要的一切都在 /usr/ 中。

回答by Craig B.

The best thing to do is actually to download and install the new Command Line Developer Tools package from Apple, which gives you your tools in /usr/bin along with libraries in the proper place and documentation (e.g. manpages). Either go find it on developer.apple.com or check herefor details and a link.

最好的办法实际上是从 Apple 下载并安装新的命令行开发工具包,它为您提供 /usr/bin 中的工具以及适当位置的库和文档(例如联机帮助页)。要么在 developer.apple.com 上找到它,要么在此处查看详细信息和链接。

回答by dualed

I just ran into this... I "solved" it by just installing the XCode "Command Line Tools" package

我刚刚遇到了这个......我通过安装 XCode“命令行工具”包来“解决”它

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

但是由于某种原因,在项目打开时(至少对我而言)不可能到达相同的首选项窗口。我必须执行以下操作

  • Close XCode (if running)
  • Start XCode (do notopen a project yet)
  • Press Command+,
  • Go to Downloads
  • Click on install
  • 关闭 XCode(如果正在运行)
  • 启动 XCode(还没有打开项目)
  • 按 Command+,
  • Downloads
  • 点击 install

回答by William Pursell

njamesp is correct; the proper solution to your problem is to get your compiler tool chain correctly installed. But to the question Where do I setup configure's paths?, there are a couple of solutions.

njamesp 是正确的;解决问题的正确方法是正确安装编译器工具链。但是对于我在哪里设置配置路径的问题?,有几个解决方案。

  1. Pass it to configure as a command line option: /path/to/configure CC=/p/a/t/h

  2. (Deprecated-bourne shell) Pass it in the environment: CC=/p/a/t/h /p/t/configure

  3. (Deprecated-csh) env CC=/p/a/t/h /p/t/configure

  4. setup a config.site. Put CONFIG_SITEin your environment as the path of a file, (eg export CONFIG_SITE=$HOME/config.site), put CC=/p/a/t/hin that file

  5. put CC=/p/a/t/hin /usr/local/share/config.site

  1. 将它传递给配置为命令行选项: /path/to/configure CC=/p/a/t/h

  2. (Deprecated-bourne shell) 在环境中传递它: CC=/p/a/t/h /p/t/configure

  3. (已弃用-csh) env CC=/p/a/t/h /p/t/configure

  4. 设置一个 config.site。放入CONFIG_SITE您的环境作为文件的路径(例如 export CONFIG_SITE=$HOME/config.site),放入CC=/p/a/t/h该文件

  5. CC=/p/a/t/h/usr/local/share/config.site

All of this assumes that your configure script was generated by autoconf. Options 2 and 3 are discouraged, but if your configure script is ancient option 1 may not work. Option 5 is flexible, and you can use different config.sites depending on prefix. $prefix/share/config.site can be used to set options for projects installed in $prefix.

所有这些都假设您的配置脚本是由 autoconf 生成的。不鼓励使用选项 2 和 3,但如果您的配置脚本是古老的,则选项 1 可能不起作用。选项 5 很灵活,您可以根据前缀使用不同的 config.sites。$prefix/share/config.site 可用于为安装在$prefix.

回答by alevanpa

Item 1 correct: I just did the same thing.

第 1 项正确:我刚刚做了同样的事情。

Install XCODE Launch XCODE Click on Xcode Choose Preferences Click on Downloads in the XCode Preference pane Click on command line tools and click "Install"

安装 XCODE 启动 XCODE 单击 Xcode 选择首选项 单击 XCode 首选项窗格中的下载 单击命令行工具并单击“安装”

The compilers are install in /usr/bin

编译器安装在 /usr/bin

cd there, and type "gcc -v"(without the quotes)and you should get back the following:

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)
$ 

回答by AlphaZygma

I recently installed OSX Mavericks and wanted to upgrade to php 5.5.5 and faced a similar issue

我最近安装了 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

Looking at my include path, I noticed that only de base Xcode path was added (I have Xcode 5)

查看我的包含路径,我注意到只添加了 de base Xcode 路径(我有 Xcode 5)

[user@host ~]$ cat /etc/paths
/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin
/bin
...

All I needed to do is add the path to the Toolchains

我需要做的就是添加工具链的路径

[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
...

And voilà, it found it.

瞧,它找到了。

[user@host /path/to/php5.5.5_src]$ ./configure
checking for cc... cc
checking whether the C compiler works... yes

Hope this helps.

希望这可以帮助。