Saturday, May 29, 2010

Building on and for Knoppix

The Knoppix Live CD ( is an excellent way to try out Linux on any PC with a CD-ROM drive. It won't store anything on your PC (unless you ask it to) and doesn't mess up any existing installations of Linux or Windows.

In this article, I'm going to describe how to build ROLF to run on Linux assuming a PC booted from an unmodified Knoppix 6.2 CD.

When done, you should have a working ROLF desktop being displayed in a window, able to run a few native ROLF programs and even some RISC OS programs, in a limited way. Simply by copying the directory into which you've installed ROLF to some permanent storage (a hard disc or a memory stick, for example), you can use the build again without having to go through the steps I describe.

Set up a build environment

Knoppix, unfortunately, doesn't include all the tools needed to build ROLF, so we have to get them from Debian first. (If your Linux system already includes these tools, you can obviously skip this step.)

First, get the full list of packages that are available:

sudo apt-get update

Then update the compiler to include the C++ compiler, needed to build the Server part of ROLF (the libraries are all plain C, but to build them, you need libtool).

sudo apt-get install build-essentials
sudo apt-get install subversion
sudo apt-get install libtool
sudo apt-get install pkg-config

After that has been done, the compiler will still refuse to compile C++ programs because it can't find cc1plus, for some reason. The simplest way to fix that is to add the path to the (just installed) cc1plus file installed to the PATH environment variable.

export PATH=$PATH:$(dirname $(find /ramdisk/ -name cc1plus 2>/dev/null | head -n 1))

Now, to get the source code:

svn co ro-lf

(If you don't expect to make any changes to the code, you can instead use:
svn export

Knoppix (or Debian) have all their shared libraries taged by their version number; to make the files linkable, we need to do this:

mkdir lib
ln -s /usr/lib/ lib/
ln -s /usr/lib/ lib/
ln -s /usr/lib/ lib/
ln -s /usr/lib/ lib/
ln -s /usr/lib/ lib/
ln -s /usr/lib/ lib/
sed -i 's/CFLAGS.*$/& -L$(CFGDIR)/lib' config.mak

Similarly, the build requires a set of include files [This bit needs an update!]

Specifically, the files needed are:

From zlib:
zlib.h, zconf.h

From libpng:
png.h, pngconf.h

From file:

From libjpeg
jpeglib.h, jmorecfg.h, jconfig.h

From freetype 2:

sed -i 's/CFLAGS.*$/& -I$(CFGDIR)/my_includes' config.mak

Change directory into the downloaded code and run configure (not as complicated as a normal configure script) and build ROLF:

cd ro-lf/ROLF/rolf
./configure --appsdir=$HOME/Apps --prefix=$HOME --tarballs=`pwd`/tarballs/

Assuming all goes well with the build, the next step is to collect the resources needed in one place.

You will need:

  • Fonts (at least FreeSerif.ttf; the default font)
  • Tool and Icon sprites (I use Chris Wraight's Steel theme, from here:
  • A mimemap.txt file (if you're going to use RISC OS software)
  • and a !Boot file, to load them all (like the one below)

Create a resources directory with subdirectories:

mkdir -p Resources/fonts/{FreeSerif,FreeSans,FreeMono}
ln -s /usr/share/file/ Resources/
cd Resources/fonts
for i in *; do for f in $( find /KNOPPIX/ -name $i*.ttf ); do ln -s $f $i/ ; done ; done 2>/dev/null
# This one is needed for the Terminal application:
cp `find /KNOPPIX/ -name default8x16.psf* 2> /dev/null` .
cd ..
cd ..
cat > \!Boot <<"EOF"
IconSprites $ROLF_RESOURCES/Steel/Tools
IconSprites $ROLF_RESOURCES/Steel/Icons

LoadPointer $ROLF_RESOURCES/Steel/Icons ptr_default 0 21
LoadPointer $ROLF_RESOURCES/Steel/Icons ptr_double 0 21

# Match up icons with the appropriate mime types
if [ -f $ROLF_RESOURCES/mimemap.txt ] ; then ( grep -v ^# $ROLF_RESOURCES/mimemap.txt | tr -s '\t' | cut -f 1,3 | sort -k 2 | sed 's/\(.*\)\t\(.*\)$/IconSprite file_\2 "file_\1"/' | sh ) ; fi

# Load applications
Filer Icon $HOME/Apps 50 romapps Apps
Filer Icon /tmp 40 ramfs ramfs
Filer Icon $HOME 45 homedisc Home

Now, we just have to run it!

export LD_LIBRARY_PATH=`pwd`/lib
export PATH=$PATH:`pwd`/bin

#Uncomment the next line if you need a log of what's happened (useful for debugging)
# ROLF_WIMP_LOG=/tmp/rolf_wimp_log \
ROLF_RESOURCES=`pwd`/Resources \

That should have the effect of printing:
VNC Server waiting for connections on port 2008.
New file descriptor 3
New Opaque bitmap VNCFrameBuffer, 1024x768

In another terminal window, type:

vncviewer localhost:2008

... and a colourful window with an icon bar and a couple of drive icons should appear!

I will follow this up with some more postings about running RISC OS software on ROLF, as well as implementations of NetSurf and MPlayer.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home