I am following a basic "Hello World" example from a textbook whose purpose is to create and cross-compile a simple command line program on a MacOS with Xcode and then run it on a jailbroken iPad. I use the arm-apple-darwin10-llvm-gcc-4.2 cross compiler on MacOS 10.6.8 from an Xcode 4.2 install. The sample code is:
#include <stdio.h>
main ( ) {
printf("Hello, World!");
}
and the compile I am attempting is this:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 -o hello hello.c -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
This generates an object when inspected with the file command displays:
$ file hello
hello: Mach-O executable arm
Ok. So far so good. I should be able to copy this to my iPad and use ldid.
However it fails:
MyiPad: /Applications root# ldid -S hello
codesign_allocate: object: hello malformed object (unknown load command 8)
util/ldid.cpp(582): _assert(78:WEXITSTATUS(status) == 0)
In addition, if I run strings back on the MacOS, it displays the same error.
$ strings hello
strings: object: hello malformed object (unknown load command 8)
My belief is that there is something wrong with the configuration or setup of Xcode. Or I have not had enough coffee yet. But this is a textbook example so clearly I am missing something in my setup. I have also tried setting up the iPhoneOS5.1.sdk with the platforms, sdk, and Sim directory as per iOS 5.1 with Xcode 4.2 and retina in iPad 3
Any pointers greatly appreciated.