Compiling C/C++ program for the OLPC
Background
Last week I found a bug in the FBReader program and I wanted to compile a new executable for my OLPC with my bugfix. Unfortunately my development system is already updated to Fedora 8 and the executable that I get contained dependencies on shared libraries that only have older versions on the OLPC. This is not very surprising. But the question was how to create a development environment that easily lets me create executables with the correct shared library dependencies. I'm sure there are several method, but the method I used is based on chroot, and should work on any modern Linux based distribution.
The chroot OLPC environment
The idea is to create a complete copy of the olpc disk contents on my desktop and then chroot into this enviroment. While in the chroot environment I can do yum install to install all the development tools that I need for the compilation.
Here are the exact steps:
- On your desktop do:
su mkdir /home/olpc/dev cd /home/olpc/dev mkdir dev/null c 2 2 mkdir proc chmod 0666 dev/null mkdir src
- On the olpc do:
su cd / rsync -a bin sbin lib usr desktop:/home/olpc/dev scp proc/cpuinfo desktop:/home/olpc/dev/proc
where desktop is the ip of your desktop. (You will also have to take care of the permissions of the copying through user@desktop or by using chmod).
- Now chroot into this new enviroment on the desktop:
chroot /home/olpc/dev
- In the chroot jail we can now set up the development environment through yum. To compile FBReader I needed to do the following installations:
yum -y install gcc gcc-c++ gtk2-devel make bzip2-devel libz-devel libjpeg-devel
Your milage my vary, but for a gtk program the dependencies above seem resonable.
That's it more or less. You can now develop and compile software in the chroot jail and then copy them over to the OLPC and be pretty sure that the dependencies are correct.
Good luck!
Please let me know if you found this info helpful, e.g. in my Discussion page.
-- User:Dov