xcrun -sdk macosx10.7 -run gcc -isysroot $(xcodebuild -version -sdk macosx10.7 Path) test.m -o test
test.m
#include <stdio.h>
int main(){
printf("hello world");
return 0;
}
本文介绍如何使用Xcode的命令行工具xcrun和gcc来编译一个简单的C语言HelloWorld程序。通过设置正确的SDK路径并利用xcodebuild获取版本信息,最终生成可执行文件。
xcrun -sdk macosx10.7 -run gcc -isysroot $(xcodebuild -version -sdk macosx10.7 Path) test.m -o test
#include <stdio.h>
int main(){
printf("hello world");
return 0;
}

被折叠的 条评论
为什么被折叠?