Using GNU gcc to Create and Run a Program on Jailbroken iPad

Update: June 17, 2017.  Building Lynx Browser for the iPad:  I just built Lynx-2.8.7 for the iPad.  I had to do this, because I could not get a browser that worked usefully on the iPad anymore.  Safari crashes *all* the time because of the new tricks being done by modern browser-server code (you could teach a course on all the trickery now being done with browser technology.. it is pretty sad, actually.)  The solution, of course, is to de-couple a bit, and use fine, clever, Lynx, the famous charcter-cell based browser that remains the oldest browser still in active use.  It was a bit of a trick getting it to compile.  I had to hack a bit of the code, but with gcc 4.2.1 and cpp 4.2.1 (based on Apple build #5555), Lynx 2-8-7 will complile nicely, and *with* OpenSSL (you need the "--with-ssl" flag when you run the "./configure"), and the SSL libs on the iPad, of course.   A typical "./configure, ./make, and ./make install" works fine, and you get a running Lynx browser.  Note, you have to run Mr. Freeman's excellent little "ldid -S <path to your lynx binary>", or the wicked Apple iOS operating system will reward your efforts with a "killed 9", as I explain below in the simple "Hello World" example.  Two images at bottom, showing a startup shell script for accessing Google News, US Edition, and what you can do using the lynx.lss file to make Lynx look like a real browser (you can tweak all the colours and reverse video options.).  Plus, if you use "-dump", you can build a simple robot to capture web-page data, assuming it is not hidden or obfuscated by little tricks.

How to run a simple C/c++ program on your iPad

I had been using DOSpad for any non-APL C/c++ programming, but discovered gcc can be run natively on the iPad.  It turns out Python and even X11 can be built to run locally on the iPad.  For those new to jailbreaking iPad's, here is a photo-essay on how to run a C program native on the iPad.  (Note: I only tested this on my old iPad gen-1, running iOS 5.1.1).

First, jailbreak your iPad, and then, using Cydia, download the GNU C Compiler, from Jay Freeman's (aka Saurik's) repository.  These software repositories (or "repos") are how one gets and loads Debian package files (.deb files) onto the opened-up (jailbroken) iPad.  A .deb file is like a .apk file (for those with Android package development experience). 

To start, press Cydia icon from the Springboard (main UI screen) on iPad, and use search (magnify-glass at screen-bottom icon set) for "gcc", the GNU gcc C-language compiler.   You should also make sure you have the "MobileTerminal" packege installed, so you can bring up a command line screen, where you can enter unix-style shell commands.  (The icon that says "Terminal", beside the Cydia icon).  Jailbreaking should install Cydia, but you may need to add other "repos" (software repositories) to your search-list.  To do this, press "Source" at screen bottom when in Cydia, then press "Edit" in top right-top screen corner, then press "Add" in left-top screen corner.  Enter the URL of the repo in the pop-up box, and press "Done" button, top-screen right side.  As the source loads, it should report a bunch of gpg keys being verified, as per the image to the right of this text here.

Steps:  1) Use Cydia to load package "GNU gcc" from Jay Freeman's repo.

2) Use iFile (from BYA repo) or good old vi/vim to code up a "Hello World" program.  You might have to locate and install vim if you want to find that fine old workhorse.

3) Using Terminal, try to compile your "hello.c" program.  (Watch it fail!)

4) Switch from default jailbreak userid "mobile" to "root", using su.

5) Try to compile it again.  (Watch it get *killed* by the iPad O/S... !)

6) Use the "ldid -S <full path name of your new executable>" to remove Apple's security restrictions, which kill any process not known to iOS. Once security restrictions removed from "Hello", you should be able to enter "./Hello", and the executable should run.  Remember that "ldid -S" needs to be followed by the full pathname of the runnable file, in this case: "/var/mobile/dev/Hello".

7) Get Python 2.7, from Cydia Repo "".  You can also pickup a version of libgcc from this site as well.  Just install the  repository, and select package Python under "Scripting".  This installs Python 2.7.3 on the iPad, and it appears to work well.  So far, I have been unable to get "numpy" to import, however.

8) Get Lynx-2-8-7, and built your own character-cell browser (no graphic adverts or video - just the text, please...).   This was latest trick, and has made it possible to screen-scrape harvest a bunch of useful stuff from several places.    I started with a DOSbox version of Lynx, and the Swsvpkt packet driver - running in Windows cmd shell, just to see if it would work.  Yup, it does.  I found the old virtual packet driver at: but you don't need this if you are not using DOSbox or Windows Cmd shell to run Lynx.  You can just build it right in Linux/Unix with the gcc 4.2.1 and the cpp (c preprocessor) also 4.2.1, that installs on the iPad.  You run the compile and make on the iPad directly, and use "--with-ssl" as an option to the ./configure run, to complile in the ssh stuff needed for "https:" webpages.   You might have to tweak the opts in lynx.cfg and lynx.lss to get sane operation.  Also, the lynx.cfg and lynx.lss files are best put into /usr/local/etc, that is default in the ./configure.  You can also point to them on the Lynx command line when you run it.  They are necessary for it to work.  The source for the Lynx 2.8.7 I used is:   I also built this browser for a CentOS 6.6 Linux box, and my hacked/custom-built version of Fedora Linux (circa 2009), as well as for Windows Cmd shell, using the little virtual packet driver above (it connects the Windows network stuff to the lynx-dos stuff - basically, it is a virtual device driver, which lets Windows Command shell act like an old DOS with a crynwr driver on the network card.  I did not expect LynxDOS to work, but it does.  There apparently was this packet-radio stuff that used DOS and that driver, to allow packet radio to run on Win-XP platforms.  But if your platform is the jailbroken iPad, or a Linux box, you can just compile Lynx using gcc and cpp.  You might have to comment out some of the 64-bit defines in the lynx code to get it to compile on the iPad.  Have fun!

The screenshots below show examples. Hope this helps jailbreaking newbies (like me!).  Once you can run gcc, then a range of applications can be built from source.  Some folks compile Python from source, and one fellow has even built a full X11 environment, running FVWM, on his iPhone, a few years back.  

Standard Caveat:  All this activity is experimental, unsupported, and at your own risk, of course. 

Main UI Screen on iPad, Showing Cydia icon. Touch it!

Search for "gcc". You should see the "GNU C Compile" from repo ""

Start "Terminal", and use vi or vim to create "hello.c" test program.

First Attempt at Compile Results in Error-Spew.

Use "su" and become root. Program compiles OK, but "Killed: 9" happens when run.

Success! Use "ldid -S <full pathname of file>" to remove Apple restrictions on the "Hello" program. It can then be run.

Ok, lets do something useful here. I downloaded the source for Lynx-2-8-7, made some minor fixes to get it to compile, and built a running version of Lynx, complete with OpenSSL, so it would work on "https://" type pages. This has turned out to be a very useful hack.

And there we have it! Page 25 of 36, from Google News, June 17, 2017, rendered by the Lynx browser, running native on the iPad. You run Lynx from the iPad "Terminal", using the "./lynxrun" example I show in the previous screen. I had to tweak the "-user-agent" string a bit so the webservers would play nice with Lynx. I really like this. You can get some useful information, but your device is not turned into a flashing billboard. A million-person city on Mars? Sounds like Blade Runner ... "A new life awaits you in the off-world colonies! A chance to begin again in a golden land of opportunity...!"