-----------------------------------------------------------------------------
工具链
-----------------------------------------------------------------------------
1.安装redhat5,下面是gcc/g++ 3.4.6 for i686-elf的工具链
2.安装工具链(版本: gcc-3.4.6, binutils-2.19, uclibc-0.9.28)
cd /data
tar jxf gcc-3.4.6.tar.bz2
mv gcc-3.4.6 gcc-3.4.6.1 # gcc1
tar jxf gcc-3.4.6.tar.bz2
mv gcc-3.4.6 gcc-3.4.6.2 # gcc2
tar jxf binutils-2.19.tar.bz2
tar jxf uClibc-0.9.28.tar.bz2
# 编译binutils
cd /data/binutils-2.19/
./configure --target=i686-linux --prefix=/opt/i686 --disable-nls
make && make install && echo "succ----"
# 编译gcc,注意下面不要使能c++
cd /data/gcc-3.4.6.1
export PATH=/opt/i686/bin:$PATH
./configure --target=i686-linux --prefix=/opt/i686 --disable-nls --enable-languages=c --without-headers --with-newlib
make && make install && echo "succ----"
# 编译uclibc
export PATH=/opt/i686/bin:$PATH
cd /data/uClibc-0.9.28
# 如果使用0.9.29参考里面的补丁,比较繁琐
先make menuconfig不保存,然后
cp extra/Configs/Config.i386 .config
make menuconfig
配置: "Target Architecture Features and Options"里面的"Linux kernel header location"设置成(/usr/src/kernels/2.6.18-164.el5-i686);
以及"Enable full C99 math library support"打勾, 否则minigui-1.6.10依赖的cbrt和hypot找不到
配置: "Library Installation Options"里面的参数设置如下:
(/lib) Shared library loader path
(/) uClibc runtime library directory
(/usr/) uClibc development environment directory
配置: "Networking Support"里面的"Remote Procedure Call (RPC) support"选中
make CROSS=i686-linux- && echo "succ--------"
make PREFIX=/opt/i686 install && echo "succ--------"
cd /data/uClibc-0.9.28/utils
make ldd.host
cp ./ldd.host /opt/i686/bin/i686-linux-ldd
# 编译final gcc
cd /data/gcc-3.4.6.2
编辑里面的./gcc/config/linux.h最后面加上
../gcc-3.4.6/configure --target=i686-linux --prefix=/opt/i686 --disable-nls --enable-languages=c,c++
修改./gcc-3.4.6.2/gcc/c-incpath.c, 在add_standard_paths()函数中有2个add_path()函数调用, 在第二个前面加上:(不需要)
if(0 == strcmp("/usr/local/include", str))
continue;
if(0 == strcmp("/usr/include", str))
continue;
make && make install && echo "succ----"
#调整toolchain
编辑/opt/i686/lib/gcc/i686-linux/3.4.6/specs把里面的dynamic-linker /lib/ld-linux.so.2
改成dynamic-linker /lib/ld-uClibc.so.0或者/opt/i686/lib/ld-uClibc.so.0
# 测试工具链
编写hello, world程序, i686-linux-gcc hello.c -v