Archives

All posts for the month May, 2006

Building a cross-compiler on RedHat Enterpirse Linux 3 WS

First you’ll need to recompile the binutils package with the –target machines name.

For example: mips-linux, sparc-linux, etc.

The easiest way to do this is to download the source .RPM for the running version of binutils on the host system.

Rpm –q binutils (To see the current version)

Up2date –get-source binutils

Will place the .src.rpm in /var/spool/up2date

Extract the source with:

Rpm2cpio /var/spool/up2date/binutils-`version`.src.rpm | cpio –extract

Then extract the tarball with:

Tar jxvf binutils-`version` (replace j with t if your archive is a .gz)

I like to keep it clean and build outside the source, so I do:

Mkdir build-binutils && cd build-binutils

Export target=`your target here`, for example:

Export TARGET=mips-linux

Export PREFIX=/usr/local

../binutils`version`/configure –target=$TARGET –prefix=$PREFIX

If you specified an invalid target, configure will complain.

Make && make install

You should end up with some binaries prefixed with your target architecture in /usr/local/bin as well a /usr/local/`target`, with a bin and lib beneath that directory.

Next, you need glibc (or possibly uClibc).

Up2date -i