![]() |
Cross-Compiling from Debian on a PC to OpenDebianSlugThis page describes two ways to set up a cross-compilation environment for OpenDebianSlug on a Debian PC. You can either install binary packages, or do it yourself. Installing from binary packagesPre-built cross-compiler packages resulting from the steps
described in the rest of this page be found at In that directory you'll find a set of .deb files. You'll also find a .tar.gz file containing all of the compiler and library files. This is not a .deb file so the Debian package system won't know anything about it, and it may be possible to use it on other systems. (Note: I don't think that these packages include the gcc-3.3 patch mentioned below, so they won't work with the current version of dpkg-cross.) Doing It YourselfThere are three main steps:
These steps are described in the rest of this page. Things are easier now that big-endian ARM has some Debian support; if you're using an old Debian system you may need to hack things a bit. Look at the history of this page for the now-deleted details. Installing the OpenDebianSlug librariesYou need the OpenDebianSlug libraries and include files on the PC so that your programs can be linked with them. You need to install a few basic libraries before starting work on binutils and gcc because they make use of them during installation. You can add other libraries, as needed by your programs, later in the same way. You cannot just install the OpenDebianSlug .debs on your PC for two reasons. First, the Debian installation tools will refuse to install them because they are for the wrong architecture. Second, you don't want to replace your native PC libraries with ARM code; these libraries must be installed in a special location. Both of these issues can be fixed by using the dpkg-cross tool to convert the .debs. So install dpkg-cross, if you don't already have it. You probably also need fakeroot:
(You need a version of dpkg-cross >= 1.26 for big-endian ARM support.) You should review Now get the OpenDebianSlug .debs for at least the following libraries:
It's probably easiest to wget them from http://ftp.armeb.net/debian-sarge/pool/main/. These files will have names ending Convert them using dpkg-cross as follows:
This will generate a new .deb for each package. The new filename will end
Building binutilsVersion 2.17 of binutils should build without patching. For older versions, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=231707 and the history of this page. The build procedure is as follows:
(You should be able to run apt-src is a normal user, but running as root means that it will be able to install the native tools necessary for building binutils automatically. You'll then need to chown it all so that you can build as a normal user.)
Now build the tools:
(Note that it's now armeb-linux-gnu, not just armeb-linux.) This will create a .deb, which you need to install:
Building gccBefore you start working on gcc, check that you don't have a buggy version of awk. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=303263. Try this:
It should do nothing. If you see an error message you need to upgrade from 1:3.1.4-2 (=sarge) to 1:3.1.4-2.0.1 (>=etch). The Debian gcc package has support for building cross-compilers built in, now including the necessary patches for big-endian ARM, even in the gcc-3.3 packages. If you're targetting a stable OpenDebianSlug NSLU2 you'll want gcc-3.3; if your target is more up-to-date you can use a newer version of gcc. This page assumes gcc-3.3.
Unfortunately this patch isn't quite right, at the time of writing (Aug 28 2006). You need to replace references to GCC_SO with CXX_SO in places where libstdc++ is mentioned. Then: $ patch -p1 < 357629.patch You might like to review debian/README.cross at this point. Now you can compile:
This will create several .debs including gcc and g++ and their run-time libraries. Note that the resulting .debs depend on gcc-3.3-base, which is shared with your native compiler, and must be the same version. You may need to install or upgrade it. You can now install your new cross-compiler:
TestingYou can test the tools as follows:
Copy the executable to your slug and see if it works!
view ·
edit ·
print ·
history ·
Last edited by Phil Endecott.
Based on work by Phil Endecott, dyoung, martin w, marcusb, hs, rwhitby, buytenh, and Leak. Originally by Phil Endecott. Page last modified on August 28, 2006, at 10:51 PM
|