Compiling C/C++ program for the OLPC: Difference between revisions

From OLPC
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 23: Line 23:
su
su
cd /
cd /
rsync -a bin sbin lib usr desktop:/home/olpc/dev
rsync -a bin sbin lib usr etc desktop:/home/olpc/dev
scp proc/cpuinfo desktop:/home/olpc/dev/proc
scp proc/cpuinfo desktop:/home/olpc/dev/proc


Line 39: Line 39:


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.
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.

== su in the chroot jail ==

If you feel uncomfortable working as the root in the chroot jail then you can su to the user olpc. Unfortunately this does not work as the fedora 7 su program uses PAM authentification. One way to get around this is to grab coreutils and recompile it, and copy the resulting su executable to /bin/su.

See:
:[http://tjw.org/etded/su.php http://tjw.org/etded/su.php]


Good luck!
Good luck!

Revision as of 12:13, 25 January 2008

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 etc 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.

su in the chroot jail

If you feel uncomfortable working as the root in the chroot jail then you can su to the user olpc. Unfortunately this does not work as the fedora 7 su program uses PAM authentification. One way to get around this is to grab coreutils and recompile it, and copy the resulting su executable to /bin/su.

See:

http://tjw.org/etded/su.php

Good luck!

Please let me know if you found this info helpful, e.g. in my Discussion page.

-- User:Dov