Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross compile ARM on OSX x86-64

Tags:

c

xcode

macos

ios

llvm

I want to compile a simple helloworld.c on my Mac and then send it to my iphone 4 to run.

the code is pretty simple:

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

My setup:

OSX El Capitain 10.11

Xcode 7.2

Iphone4 with iOS 7.1.4 JB

clang -v Apple LLVM version 7.0.2 (clang-700.1.81) Target: x86_64-apple-darwin15.3.0 Thread model: posix

gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 7.0.2 (clang-700.1.81) Target: x86_64-apple-darwin15.3.0 Thread model: posix

iPhoneOS9.0.2.sdk

All the info that I found on the web are not useful, because of new Xcode or because of the new compilers on recent OSX.

like image 276
Mario Avatar asked Jan 26 '16 09:01

Mario


1 Answers

The correct configuration for the compiler was

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

This will produce a arm binary unsigned.

If your JB device need file signing, use ldid for this.

like image 57
Mario Avatar answered Nov 19 '22 04:11

Mario