x86_64のUbuntu 16.04および16.10でMIPS32R2クロスコンパイル環境を構築

注:mips32r6やIEEE754R-2008を使う場合はこの方法ではできません
>>26,>>27の方法でやってください


$ sudo apt-get install qemu
$ sudo apt-get install g++-mipsel-linux-gnu

これで終わり


コンパイル方法
$ mipsel-linux-gnu-gcc -o test01 test01.c

数学ライブラリを使った場合は
$ mipsel-linux-gnu-gcc -o test01 test01.c -lm


アセンブル方法(アセンブルソースはtest01.s)
$ mipsel-linux-gnu-as -a=test01.lst -o test01.o test01.s
$ mipsel-linux-gnu-ld -o test01 test01.o

gccでアセンブルソースを出力させてアセンブルする方法
$ mipsel-linux-gnu-gcc -S -o test01.s test01.c
$ mipsel-linux-gnu-as -a=test01.lst -o test01.o test01.s
$ mipsel-linux-gnu-gcc -o test01 test01.o


qemuでの実行方法
$ qemu-mipsel -cpu 24kf -L /usr/mipsel-linux-gnu test01


これを実行すれば直接コマンドラインから実行できるようになる
export QEMU_LD_PREFIX=/usr/mipsel-linux-gnu