Cross-compiling with DebWrt

Introduction

Some packages, like the Linux kernel are to big to be compiled on the device(native) itself. We need a cross compile environment for that. DebWrt uses Emdebian to setup a cross-compile environment and to cross-compile some essential packages ported from OpenWrt. It is relatively easy to setup and use the cross compile environment to compile other packages.

Setting up the DebWrt cross compile environment

Checkout DebWrt from SVN. Then run menuconfig to select the architecture you want to setup the cross compiler(buildenv) for. Then create it. A Debian change root (chroot) will be created. A lot of Debian compile and build related packages will be installed, as well as Emdebian. Emdebian contains the cross-compilers and the corresponding binutils.

make menuconfig
make debian/buildenv
make chu

With make chu, you enter the buildenv chroot as the current user. You can also use make ch to enter the chroot as root.

Cross-compiling Debian source packages

There is a lot to share about this subject. But for now I would like to give a pointer to the cross compiled DebWrt packages. It contains a lot of 'hidden' knowledge on how to get things compiled in several situations.

http://dev.debwrt.net/browser/trunk/debian/package

Some suggestions:

  • Sometimes the debian/rules file needs to be adjusted tell it to use the cross compiler
  • Sometimes the Makefile of a package needs adjustment
  • dpkg-buildpackage -a <ARCH> is your friend :-)
  • Use dpkg-cross to convert a package into a 'Debian cross' and install it. This is needed when a package its compile process depends on another package.
  • Try apt-cross to retrieve and automatically install cross-compile development Debian packages, or download and install manual
  • note: apt-cross does not always work well. I recall there was a tool created, but don't know if it is available yet.
Last modified 6 years ago Last modified on Aug 14, 2011, 3:54:59 PM