I EVENTUALLY managed to get back to where I was yesterday after I hit a bump in the road where I stepped back and could no longer compile simple applications on my Mac OSX destined for the iPhone arch. This time, I have created a simple script called ‘gcc2’ which sets all the appropriate options.
#!/bin/sh
GCC=”/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc”
ISYSROOT=”/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk” #3.1.3
EXPECTED_ARGS=3
# check num of args supplied
if [ $# -ne $EXPECTED_ARGS ]
then
#print usage
echo “Usage: `basename $0`: no input files”
exit -1 #exit on error
fi
# e.g. gcc -arch armv6 -isysroot $ISYSROOT -o test test.c
$GCC -arch armv6 -isysroot $ISYSROOT $1 $2 $3
abnev-lpt2:iphone-gcc abnev$ cat test.c#include <stdio.h>int main() {printf(“Hello, World!\n”);return(0);}abnev-lpt2:iphone-gcc abnev$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/abnev-lpt2:iphone-gcc abnev$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -o test test.cabnev-lpt2:iphone-gcc abnev$ cd ~abnev-lpt2:~ abnev$ mkdir binabnev-lpt2:~ abnev$ cd binabnev-lpt2:bin abnev$ pico gcc2abnev-lpt2:bin abnev$ PATH=$PATH:/Users/abnev/binabnev-lpt2:bin abnev$ chmod 755 gcc2abnev-lpt2:bin abnev$ gcc2arm-apple-darwin10-gcc-4.2.1: no input filesabnev-lpt2:bin abnev$ cp ~/test.c .abnev-lpt2:bin abnev$ gcc2 -o test test.cabnev-lpt2:bin abnev$ ./test-bash: ./test: Bad CPU type in executableabnev-lpt2:bin abnev$Just an extra note, to make sure the environment would be set up after reboots etc I modified my ~/.profile to include the correct PATH environment variables pointing towards ~/bin where gcc2 now resides. This was done by adding/changing the line:
export PATH=/opt/bin:/opt/local/bin:/opt/local/sbin:$PATH
to
export PATH=/Users/abnev/bin:/opt/bin:/opt/local/bin:/opt/local/sbin:$PATH
I’ll continue trying to get it to compile using libpcap.
