How to build crosscompilers



All timestamps are based on your local time of:

Stolen from http://www.ifp.uiuc.edu/~nakazato/tips/xgcc.html

1) Get latest sources for binutils, gcc-core, newlib, and gdb.

2) Select a target architecture (e.g. powerpc-elf, mips-elf) and run the following commands:

export TARGET=powerpc-elf
export PREFIX=/usr/local/$TARGET
export PATH=$PATH:$PREFIX/bin



3) Build binutils:

tar xjf binutils-*.bz2
mkdir build-binutils
pushd build-binutils
../binutils-*/configure --target=$TARGET --prefix=$PREFIX
make all
make install
popd



4) Build gcc:

tar xjf gcc-*.bz2
mkdir build-gcc
pushd build-gcc
../gcc-*/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld
make all-gcc
make install-gcc
popd



5) Build newlib:

tar xzf newlib-*.gz
mkdir build-newlib
pushd build-newlib
../newlib-*/configure --target=$TARGET --prefix=$PREFIX
make all
make install
popd



6) Rebuild gcc with newlib:

pushd build-gcc
../gcc-*/configure --target=$TARGET --prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp
make all
make install
popd



7) Build gdb:

tar xjf gdb-*.bz2
mkdir build-gdb
pushd build-gdb
../gdb-*/configure --target=$TARGET --prefix=$PREFIX --enable-sim-powerpc --enable-sim-stdio
make all
make install
popd



8) Compile your code:

powerpc-elf-gcc hello.c -o hello



9) Run your code:

powerpc-elf-run hello

[ Add a new comment ]

 
 
(c) Kartikaya Gupta, 2004-2024. User comments owned by their respective posters. All rights reserved.
You are accessing this website via IPv4. Consider upgrading to IPv6!