How to build crosscompilers

All timestamps are based on your local time of:

Stolen from

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

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

5) Build newlib:

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

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

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

8) Compile your code:

powerpc-elf-gcc hello.c -o hello

9) Run your code:

powerpc-elf-run hello
Allowed expansions in comments/replies: [i]italic[/i], [u]underline[/u], [b]bold[/b], [code]code[/code], [sub]subscript[/sub], [sup]superscript[/sup], [url=http://some.url]linked text[/url]
Human verification: Sum of twenty and twenty-two =
(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!