문제

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

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.

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.

Ideas?

도움이 되었습니까?

해결책

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

The Apple developer web site is my friend

다른 팁

From Xcode 4.3, open Preferences and select the Downloads icon. In the Components pane, you can install "Command Line Tools".

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-select was enough for command line builds to work again.

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.

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top