Pad Code AI
Compile and run C on iPad in a Linux terminal with Pad Code AI
Create a C project in Pad Code AI on iPad, run it, then compile with gcc and make in the Linux terminal and install a library with apt.
Pad Code AI runs Ubuntu Linux on your iPad or iPhone, so C is compiled with the same commands you would use on a computer: gcc, make and apt. This guide builds a small program three ways: with the Run button, in the terminal and with a Makefile.

Create a C project
- On the home screen, choose New Project, pick C Program and choose a location in Files.
- Open
main.cand replace its contents with the example below.
#include <stdio.h>
int main(void) {
int minutes[] = {18, 25, 12};
int total = 0;
for (int i = 0; i < 3; i++) {
total += minutes[i];
}
printf("Reading time: %d minutes\n", total);
return 0;
}
Run it
With main.c open, tap Run. The first time, the app offers to download Linux and the C and C++ tools, a few hundred megabytes; after that they work offline. The output should read Reading time: 55 minutes.
Compile in the terminal
Open the Command Palette and choose Linux Terminal. The shell starts in /workspace, which is your project folder, so files you create there appear in the editor and the other way round.
gcc -Wall -O2 main.c -o main
./main
gcc, g++ and clang use a compiler built into the app, so a small program compiles in well under a second. -Wall turns on the warnings worth reading; fix them before moving on.
Build with make
Create a file named Makefile next to main.c. The command line must start with a tab, not spaces.
CFLAGS = -Wall -O2
main: main.c
$(CC) $(CFLAGS) main.c -o main
make
./main
Run make again without changing anything: it reports that main is up to date. Change a number in main.c, run make once more and only then is the program rebuilt. Larger projects build on several processor cores without extra options.
Add a library with apt
Ubuntu’s packages are available in the terminal. Installing one needs an internet connection the first time. For example, for a program of your own, app.c, that uses SQLite:
sudo apt install -y libsqlite3-dev
gcc -Wall app.c -o app -lsqlite3
If something does not work
gcc: command not found: download the C and C++ tools in Settings › Run & Terminal › Linux › Tools for Offline Use.missing separatorfrom make: the command line in the Makefile starts with spaces. Replace them with one tab.- The program prints nothing: check that the
printftext ends with\nand that you ran./main, notmain.
Next, debug a Python script with breakpoints or see the Pad Code AI page for the other languages and tools.