Test Source Code 'name.c':
[php]#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
if(argc <= 1) {
printf("[!ERROR!] %s", "Not Enough Paramsn");
return 0;
}
char* name = argv[1];
unsigned int i;
for(i = 0; i < 10; i++)
printf("Message: %s n", name);
return 0;
}[/php]Prerequisites :
- Basic C programming knowledge.
- Slightly familiar with the unix command line
- Basic networking knowledge
- LAN\WIFI connection to PC's SSH client.
I'll explain everything but jailbreaking in this tutorial.
If it's your first time opening cydia, it will ask you which kind of user you are, select Developer. This will remove all the filters and allow you to access ToolChain(which contains GCC, the unix C++ compiler you'll be using)
Step 1 : Jailbreak your Ipod\Iphone
Step 2 : Open Cydia and download MobileTerminal
Step 3 : Open Cydia and download Automatic SSH
Step 4 : Open Cydia and download Toolchain
Step 5 : Open up windows, download and install WinSCP
- After all these have been installed, reboot your Iphone\Ipod.
- Go to setting from the SpringBoard(desktop of the Ipod)
- From setting go to Generel > Network > Wi-Fi, select the blue arrow next to your connection(it must be locally connected to the PC)
- Write down the Ip Address.
- Open WinSCP, under host name put the IP Address you just wrote down, User : root, password : alpine(default).
- Leave all the rest as they are. Now, connected to your Ipod touch by selecting "Login", if it fails, try again 3 times.
- Once you login you should see all files and directorys(even system-level files) in your Ipod Touch. All these can be modified, deleted and created.
- Open up the terminal, which can be accessed on the Ipods 'Desktop'.
- Reconnect WinSCP
- Create a fold you will place all your C and object files. I suggest (root\private\var\ccode) Remember the console is CASE-SENSITIVE, so try to keep all your file names and dirs lower-case.
- In the console type cd /var/ccode/ This will select the ccode directory you just created, set it's permissions to 0777 via MobileCommandline or WinSCP.
- Upload a source file to /var/ccode/, name it source.c. When programming this, be careful with memory\CPU usage. You can see my example of C code that I wrote to test on my compiler above.
Compiling name.c
- In MobileCommandline, navigate to your ccode directory using the cd command
- Type the following commands
- gcc name.c
- chmod 0777 a.out
- ldid -S a.out
Now the file is compiled, to run it, type ./a.out
More information :
The gcc command can be given parameters such as -o to specify the output file instead of the default a.out. Note, if you really wanted to(i have for when I'm at school) you can download a text editor and program\compile with just the Ipod touch, even though this is a bit of hassle with the onscreen keyboard.