Gccmips
This is a general guide to install a gcc-mips cross compiler for linux. It has been tested on Ubuntu (and Ubuntu NetbookRemix) 9.04 and 9.10.
The first step is to install the following libraries:
- texinfo
- build-essential
- libncurses5-dev
- libncurses5-dbg
By typing the following commands (If you have problems installing that, you could add a GERMAN repository :) )
sudo apt-get install texinfo build-essential sudo apt-get install libncurses5-dev libncurses5-dbg
Once you have this libraries installed, you have to get the following packages:
- binutils-2.17.tar.bz2
- gcc-core-4.1.1.tar.bz2
- newlib-1.17.0.tar.gz
- gdb-6.8.tar.bz2
(It could be obtained from http://ftp.gnu.org/): Untar all:
tar xjf binutils-2.17.tar.bz2 tar xjf gcc-core-4.1.1.tar.bz2 tar xzfv newlib-1.17.0.tar.gz tar xjfv gdb-6.8.tar.bz2
Create temporal folders where you going to compile the entire gcc-mips cross compiler.
mkdir binutils-obj gcc-obj newlib-obj build-gdb
And now begin the compilation, it is explained just for one step, in this case binutils-obj (binary utilities GNU_Binary_Utilities), later of this is assumed that you know what means every command:
Enter to directory:
cd binutils-obj
Configure the compilation (It is just execute the configure file with some flags necesary like target=mips-elf prefix=/usr/local)
../binutils-2.17/configure --target=mips-elf --prefix=/usr/local
Execute the makefile using the flags necesary:
make CFLAGS="-Os -w"
And finally execute the "make install"
sudo make install
And go to the primary directory
cd..
Now the compilation of gcc-obj:
cd gcc-obj ../gcc-4.1.1/configure --target=mips-elf --prefix=/usr/local --enable-multilib --disable-libssp make CFLAGS="-Os -w" sudo make install cd..
Now the compilation of newlib-obj Newlib:
cd newlib-obj ../newlib-1.17.0/configure --target=mips-elf --prefix=/usr/local make CFLAGS="-Os -w" sudo make install cd..
Now we have to enter to the gcc-obj dir to set additional flags CFLAGS
cd gcc-obj ../gcc-4.1.1/configure --target=mips-elf --prefix=/usr/local --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp make CFLAGS="-Os -w" sudo make install cd..
Finally we go inside build-gdb dir and compile the GNU Debugger Gdb
cd build-gdb ../gdb-6.8/configure --target=mips-elf --prefix=/usr/local --enable-xspim-mips --enable-xspim-stdio make CFLAGS="-Os -w" sudo make install cd..
To compile a "hello world" program you can use for example the following command:
mips-elf-gcc helloworld.c -o helloworld
Some tools of mips-elf cross compiler are:
- Compiler mips-elf-gcc
Compile the program creating a .o file. (Object file)
- Assembler mips-elf-as
Generates a .S or .asm file (assembler file).
- Linker mips-elf-ld
Combining .o files and libraries to link it with references.
- Objdum mips-elf-objdump
Show information about a .o file (Object file)
- Objcopy mips-elf-objcopy
Generates a .bin file; copy information from a .o file to another .o file.