在OSX x86-64上交叉编译ARM

时间:2016-01-26 09:29:56

标签: ios c xcode macos llvm

我想在 Mac 上编译一个简单的 helloworld.c ,然后将其发送到我的 iphone 4 来运行。

代码非常简单:

#include <stdio.h>
int main( ) {
printf("Hello, world!\n");
return 0;
}

我的设置:

  

OSX El Capitain 10.11

     

Xcode 7.2

     

Iphone4 with iOS 7.1.4 JB

     

clang -v Apple LLVM 7.0.2版(clang-700.1.81)目标:   x86_64-apple-darwin15.3.0线程模型:posix

     

gcc -v配置:   --prefix = / Applications / Xcode.app / Contents / Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1 Apple LLVM 7.0.2版(clang-700.1.81)目标:x86_64-apple-darwin15.3.0线程模型:posix

     

iPhoneOS9.0.2.sdk

我在网上找到的所有信息都没有用,因为新的Xcode或最近OSX上的新编译器。

1 个答案:

答案 0 :(得分:6)

编译器的正确配置是

clang -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch armv7 hello.c -o hello 

这将生成一个未经签名的arm二进制文件。

如果您的JB设备需要文件签名,请使用ldid。