安装新的 xcode 4.3 后找不到 stdio.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9352171/
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-14 23:21:31  来源:igfitidea点击:

stdio.h not found after fresh xcode 4.3 installed

xcodexcode4.3

提问by Leonard

After upgrading to Lion, and installing XCode 4.3 I can't get "Hello, World" to compile.

升级到 Lion 并安装 XCode 4.3 后,我无法编译“Hello, World”。

include <stdio.h>

int
main ( int argc, char *argv[]) {

    printf("Hello, World!\n");
}


$ gcc hello.c 
hello.c:1:19: error: stdio.h: No such file or directory

I see a stdio.h in ./SDKs/MacOSX10.6.sdk/usr/include/stdio.h, but it's a little surprising that there isn't a 10.7 version. Did my install fail? It reported success.

我在 ./SDKs/MacOSX10.6.sdk/usr/include/stdio.h 中看到了一个 stdio.h,但是没有 10.7 版本有点令人惊讶。我的安装失败了吗?它报告成功。

The standard solution to this problem, after some Googling, is to reinstall XCode. But XCode is delivered through the App store with doesn't give me a re-install option. I also never saw the various other options such as "Unix development" which are referenced in other places.

这个问题的标准解决方案,经过一些谷歌搜索后,是重新安装 XCode。但是 XCode 是通过 App Store 提供的,并没有给我重新安装的选项。我也从未见过在其他地方引用的各种其他选项,例如“Unix 开发”。

Ideas?

想法?

回答by Leonard

It turns out the solution is to download the "command line tools" package. Once downloades, run the package installer and all is well. The /Developer directory is obsolete, no longer used in Xcode 4.3

事实证明,解决方案是下载“命令行工具”包。下载后,运行包安装程序,一切正常。/Developer 目录已过时,在 Xcode 4.3 中不再使用

The Apple developer web siteis my friend

苹果开发者网站是我的朋友

回答by Jeff Devine

From Xcode 4.3, open Preferences and select the Downloadsicon. In the Componentspane, you can install "Command Line Tools".

在 Xcode 4.3 中,打开 Preferences 并选择Downloads图标。在“组件”窗格中,您可以安装“命令行工具”。

Once that is installed, run the following command in the terminal:

安装完成后,在终端中运行以下命令:

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

That sorted it for me.

这对我来说是排序的。

[UPDATE]- I just had to do this again on my laptop, and I didn't need to install the Command Line Tools. After upgrading to Xcode 4.3, running xcode-selectwas enough for command line builds to work again.

[更新]- 我只需要在我的笔记本电脑上再次执行此操作,并且不需要安装命令行工具。升级到 Xcode 4.3 后,运行xcode-select足以让命令行构建再次工作。

回答by Joachim Isaksson

If you've installed Xcode from the app store and either don't have a MacOSX10.7 SDK or you want to reinstall the SDK, you can install/reinstall only that package fairly easily.

如果您已经从应用商店安装了 Xcode,并且没有 MacOSX10.7 SDK 或者您想重新安装 SDK,您可以非常轻松地仅安装/重新安装该软件包。

First check if you still have the Install Xcodeapplication in your applications folder. If it's there, good, if it's not, just go to the app store and download Xcode again.

首先检查您的Install Xcode应用程序文件夹中是否还有该应用程序。如果在那里,很好,如果没有,只需去应用商店并再次下载 Xcode。

Once you have that application, use Show package contentson it and browse to Contents/Resources/Packages. There there should be a pkg file called MacOSX10.7.pkgwhich when double clicked will install/reinstall the MaxOSX10.7 SDK.

拥有该应用程序后,Show package contents在其上使用并浏览到Contents/Resources/Packages. 应该有一个调用的 pkg 文件MacOSX10.7.pkg,双击时将安装/重新安装 MaxOSX10.7 SDK。