Racket on Android21 Jul 2012
The recent smartphones have quite impressive specs. E.g. the Samsung Galaxy S III comes with a 1.5 GHz quad-core processor and a GPU. It would be interesting though to run a real programming language on one of those phones. I am quite interested in the Racket programming language (also see Wikipedia) which offers full meta-programming and compile-time macros. I managed to cross-compile Racket to run on an Android phone HTC Desire S. I'll describe the steps here. Hopefully I'll find time to improve things and package it in some way.
To cross-compile Racket for ARM you first need to compile Racket for the host system. The GCC cross-compiler and the Racket interpreter are then used during the cross-compilation.
The last command is used to replace the racket3m binary with a statically linked version.
First I installed Android Terminal Emulator. I also installed Kevin Boone's kbox_shell which allows you to run BusyBox without requiring to jailbreak the phone (I don't think BusyBox is required to run Racket but it is nice to have the various Linux shell utilities). I really recommend to install Hacker's Keyboard to have a full PC keyboard on your phone.
Then one needs to copy the following files to the mobile phone:
- The racket3m binary is copied to the mobile in a location where it can be accessed from the terminal (e.g. /data/data/jackpal.androidterm/shared_prefs/kbox/bin/racket if you have kbox_shell installed).
- Several Racket modules located in /tmp/build/cross/racket-5.2.1/collects/... need to be copied to $HOME/.racket/5.2.1/collects on the mobile phone. The libraries are
Racket on Android Unfortunately the full Racket language takes 90 seconds (!) to load on the HTC Desire S. Once loaded, the REPL is very responsive though.
Hopefully I get ffi and the readline library working to have an improved command line.
Any comments and suggestions are welcome
It is possible to only load the Racket base language. Running the following command
brings up the REPL in 7 seconds. Thanks Robby for the helpful comment!
Racket 5.3.0 furthermore needs the following module to be installed:
I haven't managed to build Racket with the Android NDK (see my thread on the Racket mailing list). Building Racket with the Android NDK would be preferable because otherwise it is impossible to dynamically load Android libraries in order to access Android specific functionality.