步骤:
1、先编译gmp mpfr mpc这几个库,注意configure时--prefix=/usr/local/
2、中间碰到过can not compute suffix的错误,在命令
export LD_LIBRARY_PATH=/usr/local/:${LD_LIBRARY_PATH}
export LD_RUN_PATH=/usr/local/:${LD_RUN_PATH}
也不行,最后修改了/home/musictom/.bash_profile加上了如下行:
PATH="/bin/:/lib/:/usr/sbin/:/usr/local/bin/:/usr/i686-pc-mingw32/sys-root/mingw/bin/"
LD_LIBRARY_PATH="/lib/:/usr/local/lib/:/usr/i686-pc-mingw32/lib/:/usr/i686-pc-mingw32/sys-root/mingw/lib/:${LD_RUN_PATH}"
LD_RUN_PATH="/lib/:/usr/local/lib/:/usr/i686-pc-mingw32/lib/:/usr/i686-pc-mingw32/sys-root/mingw/lib/:${LD_RUN_PATH}"
就可以了
3、mkdir /home/gcc-4.7.1-i386-pc-cygwin-out
cd /home/gcc-4.7.1-i386-pc-cygwin-out
../gcc-4.7.1/configure --prefix=/usr/local/gcc-4.7.1-i386-pc-cygwin --with-gmp=/usr/local/ --with-mpc=/usr/local/ --with-mpfr=/usr/local/ --enable-shared=libgcc,libstdc++ --enable-languages=c,c++ --disable-libada --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libgomp
make
make install
原来把gdb也放在了gcc的源代码目录里,结果报找不到库termcap,弄了半天也没弄出来,最后只好把gdb的源代码拿掉
基实还需要把binutils也编译后,再安装,这个可以另外再弄,整个编译大概花了五六个小时,好了,下次再尝试编译arm的交叉编译器