[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section shows how to setup a cross compiler to compile on one machine that runs on another machine. While the examples use a host of i686-pc-linux-gnu, these instructions are generic and should work on any platform, subject to the limits of the compiler and assembler.
Prerequisites What you will need to begin. Building the Cross Compiler Step by step instructions. Additional Libraries How to deal with non-system libraries.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You should be familiar with compiling GCC and glibc before continuing. Building a cross compiler is not difficult, but you should make sure that you have enough experience before attempting this.
You will need GCC and GNU Make to begin. You cannot build a cross-compiler from the compiler that comes with most systems, and several components use GNU Make extensions. You will also need any other the programs to support these builds, like gawk, sed, bison, and friends. If you have don't know what you need, consider reviewing building gcc and glibc awhile before going on.
These instructions assume that you have write access to `/usr/local'. If you do not, you should change the `prefix'. `prefix'/bin should be in your path.
The build requires about 750 MB to complete, and the resulting binaries will consume around 300 MB.
If you are unsure of any of these steps, DO NOT CONTINUE. If a bad option is passed to `configure' or `make', you may OVERWRITE your local C library, or C compiler, leaving your system in an UNUSABLE state. You have been warned.
The following web sites can help you get started:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To begin, unpack or checkout all of your packages in a directory. Then, create a series of build directories. Your directory should look like this:
$ ls -al total 21 drwxrwxr-x 14 jbailey jbailey 1024 Dec 19 11:30 . drwx------ 77 jbailey jbailey 8192 Dec 19 11:29 .. drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:29 binutils drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 build.binutils drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 build.egcs drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 build.gcc drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 build.glibc drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 build.gnumach drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 build.mig drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:29 egcs-1.1.2 drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:29 gcc-2.95.2 drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:30 glibc-2.1.2 drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:29 gnumach drwxrwxr-x 2 jbailey jbailey 1024 Dec 19 11:29 mig $It used to be customary to build with the object directory inside the source directory, but that is no longer supported.
This step depends on some later steps to complete, so will fail with an error. Don't panic.
cd build.egcs
../egcs-1.1.2/configure --prefix=/usr/local --target=i586-pc-gnu --with-gnu-as --with-gnu-ld
make -k
make -k install
cd ..
mv /usr/local/bin/i586-pc-gnu-gcc /usr/local/bin/i586-pc-gnu-egcs
This step depends on some later steps to complete, so will fail with an error. Don't panic.
cd build.gcc
../gcc-2.95.2/configure --prefix=/usr/local --target=i586-pc-gnu --with-gnu-as --with-gnu-ld
make -k
make -k install
cd ..
ln -s /usr/local/i586-pc-gnu/ /usr/local/lib/gcc-lib/i586-pc-gnu/2.95.2/i586-pc-gnu
This is also a bad directory to delete.
cd build.glibc
../glibc-2.1.2/configure --without-cvs --enable-add-ons=crypt --build=i686-pc-linux-gnu --host=i586-pc-gnu --prefix= --disable-profile
make -k install-headers install_root=/usr/local/i586-pc-gnu
cp ../glibc-2.1.2/include/features.h /usr/local/i586-pc-gnu/include/features.h
mkdir /usr/local/i586-pc-gnu/include/gnu
touch /usr/local/i586-pc-gnu/include/gnu/stubs.h
cd ..
The stubs file will be correctly overwritten later on when we do the full glibc install. However, the file isn't generated until the last possible moment, so make install-headers doesn't pick it up.
cd build.egcs
make
make install
cd ..
cd build.gcc
make
make install
cd ..
cd build.glibc
make
make install install_root=/usr/local/i586-pc-gnu
cd ..
ln -s -f /usr/local/i586-pc-gnu/lib/libc.so.0.2 /usr/local/i586-pc-gnu/lib/libc.so
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It should be safe to simply copy any built libraries and headers into appropraite directories under /usr/local/i586-pc-gnu/
[Top] | [Contents] | [Index] | [ ? ] |
These instructions have not been tested using anything other than the C compiler. It is possible that you could build a cross-C++ (and friends) compiler using these instructions.
Both egcs-1.1.2 and gcc-2.95.2 are included here because the latest gcc will not compile gnumach or the hurd. This is due to some invalid code in those programs that used to be permissable.
[Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ < ] | Back | previous section in reading order | 1.2.2 |
[ > ] | Forward | next section in reading order | 1.2.4 |
[ << ] | FastBack | previous or up-and-previous section | 1.1 |
[ Up ] | Up | up section | 1.2 |
[ >> ] | FastForward | next or up-and-next section | 1.3 |
[Top] | Top | cover (top) of document | |
[Contents] | Contents | table of contents | |
[Index] | Index | concept index | |
[ ? ] | About | this page |