Wednesday, May 14, 2008

GCC on iPhone

On iPhone we can launch native gcc compiler. Thanks to Saurik и iGuga.

1. Install Cydia: Go to Settings -> General -> Auto-Lock -> Never.
In the Installer add source http://apptapp.saurik.com/.
Go to Install -> System -> Cydia Packager.
Installing. Wait for 8-10 mins. Cydia will move application, pics, etc. to the bigger iPhone's partition just to free space for programs like gcc or python.

2. Go to Cydia. In the right upper corner tap on the source refresh and install GNU C compiler from the section Development.

3. From section Terminal Support install MobileTerminal.

4. Download officialiPhone SDK.

5. On the iPhone delete folder /usr/lib/gcc/arm-apple-darwin8/4.2.1/include.

6. From the official iPhone SDK copy folder include and paste onto iPhone in folder /usr/lib/gcc/arm-apple-darwin8/4.2.1/.

7. Write test c-file

#include <stdio.h>

int main()
{
printf("Hello world!\n");
return 0;
}


Name it test.c

8. Put it into iPhone(for example in folder /var/mobile).

9. Launch Terminal on the iPhone.

10. Go to directory: cd /var/mobile.

11. Compile: gcc -o test test.c

12. Launch test program: ./test

14;-). Stare at terminal:

Hello world!

No comments: