我正在尝试使用命令行将mach-o arm对象文件编译为mach-o arm可执行文件。我使用过类似下面这样的各种命令
clang -arch armv7 helloapp.o -o helloapp
clang helloapp.o -o helloapp
gcc helloapp.o -o helloapp它们都会返回不同的错误,比如编译错误的架构或缺少必要的文件。我需要什么命令才能正确编译它??
发布于 2013-08-12 18:59:49
默认编译器(位于$PATH中的编译器)引用可为本地计算机编译的编译器。您需要一个知道如何创建ARM二进制文件的交叉编译器。如果你已经安装了iOS SDK的Xcode,你可以使用例如:
PATH_TO_Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc或
PATH_TO_Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang例如,在我的机器上:
ARM_GCC=~/Documents/Xcode4.6.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
IOS_SDK=~/Documents/Xcode4.6.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
# Compile
$ARM_GCC -arch armv7 -c test.c -o test.o
# Link
$ARM_GCC -arch armv7 -isysroot "$IOS_SDK" test.o -o test如果我随后运行file test,我会得到:
test: Mach-O executable armhttps://stackoverflow.com/questions/18185184
复制相似问题