I'm trying to port an existing Linux C++ application to Raspberry Pi. The application depends on a number of third-party libraries.
I'm running Ubuntu 12.04, and have built my GCC 4.7 cross-compiler using crosstools-ng (only later realising that I could have saved myself the trouble by using an officially-provided toolchain!) I'm able to produce working executables for my Raspberry. So far so good.
I then started trying to build all my third-party library dependencies: GLib, SDL and several others. Each of these dependencies had dependencies of its own, etc. It quickly became apparent that manually building ARM versions of all these libraries would be incredibly tedious and time-consuming. Is there an easier way?
After discovering ScratchBox2, I've managed to cobble together something workable. ScratchBox2 is a tool that facilitates the creation of a chroot suitable for cross-compiling and makes use of QEmu, allowing you to run foreign-CPU binaries on your computer. In my case, ScratchBox2 mediates access to a self-contained sandbox of Raspbian, an ARM-variant of Debian that's optimised for Raspberry Pi.
The upshot is that once I got it all set up—and getting it set up took several tedious hours—I was able to simply type sb2 -eR apt-get install ...
to get any required ARM packages. It's magic stuff. (Word of warning: I had no luck with the official ScratchBox2 packages in Ubuntu 12.10, so it might be best to build it yourself from source, using a recent revision from the official Git repo.)
To help you reproduce my setup more easily, I've put a Vagrant recipe for my virtual machine on Github: https://github.com/nickhutchinson/raspberry-devbox. It's almost certainly rough around the edges — this was my first experience with the Puppet provisioning tool—but hopefully others can make it more robust.
I found these resources very helpful:
Check out the openembedded build framework. It is designed to automate all of the tedious tasks of cross compiling.
The openembedded project has added support for a raspberry-pi target
You can use an openembedded distro sdk like poky or angstrom to set things up and get you started.
Poky can spit out rpm,ipk,deb. Most of them are going to work on other distros. So you dont need to use the poky distro itself.
Here is a guide on using openembedded with raspberry-pi
After that u can create a bitbake recipe or a custom oe layer defining the dependencies for your application. Take a look at the poky handbook for the relevant documentation.
Another option with or without openembedded is to load a full development environment on a qemu-arm machine and use the binaries on the production image. Openemmbedded/poky has a target image recipe for a qemu-arm sdk image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With