1.首先下载工具包
2.使用tar zxvf或tar jxvf解压下载下来的工具包;
3.为各工具包打上补丁,接下来以binutils为例,gcc和newlib步骤相同:
cd binutils-2.20.1/
cat ../binutils-2.20.1-rtems4.10-20100826.diff | patch -p1
4.安装binutils:
cd ../
mkdir build-binutils
cd build-binutils
../binutils-2.20.1/configure --target=i386-rtems4.10 --prefix=/opt/rtems-4.10 --disable-werror
make
make install
若不添加部分选项,则会出现以下错误:
../../binutils-2.20.1/bfd/compress.c: 在函数‘bfd_uncompress_section_contents’中:
../../binutils-2.20.1/bfd/compress.c:54:45: 错误: 形参‘buffer’被设定但未被使用 [-Werror=unused-but-set-parameter]
../../binutils-2.20.1/bfd/compress.c:54:68: 错误: 形参‘size’被设定但未被使用 [-Werror=unused-but-set-parameter]
cc1: all warnings being treated as errors
make[4]: *** [compress.lo] 错误 1
make[4]:正在离开目录 `/home/rtems/tools/build-binutils/bfd'
make[3]: *** [all-recursive] 错误 1
make[3]:正在离开目录 `/home/rtems/tools/build-binutils/bfd'
make[2]: *** [all] 错误 2
make[2]:正在离开目录 `/home/rtems/tools/build-binutils/bfd'
make[1]: *** [all-bfd] 错误 2
make[1]:正在离开目录 `/home/rtems/tools/build-binutils'
make: *** [all] 错误 2
5.将工具链目录添加到系统环境变量,打开/etc/bash.bashrc(之前版本的ubuntu是bashrc文件),在文件末尾加入以下内容:
export PATH=/opt/rtems-4.10/bin:${PATH}
然后使修改生效:source /etc/bash.bashrc
6.安装gcc:
由于gcc的安装依赖gmp和mpfr,gmp又依赖m4,因此首先安装m4、gmp和mpfr:
安装m4:
apt-get install m4
安装gmp:
cd ../
mkdir build-gmp
cd build-gmp
../gmp-4.2/configure --prefix=/usr/local/gmp(该部分为安装目录)
make
make check
make install
安装mpfr:
cd ../
mkdir build-mpfr
cd build-mpfr
../mpfr-2.4.2/configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp(指定gmp的安装位置)
make
make check
make install
安装gcc:
cd ../
cd gcc-core-4.4.7/
ln -s ../newlib-1.18.0/newlib
cd ../
mkdir build-gcc
cd build-gcc
在/root/.profile中加入以下内容:
export LD_LIBRARY_PATH=/usr/local/mpfr/lib:/usr/local/gmp/lib:${LD_LIBRARY_PATH}
然后使修改生效:source /root/.profile
../gcc-4.4.7/configure --target=i386-rtems4.10 --with-gnu-as --with-gnu-ld --with-newlib --verbose --enable-threads --enable-languages="c,c++" --prefix=/opt/rtems-4.10 --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr
make all(编译时间比较长,请耐心等待)
make info
make install
7.编译rtems源码包:
从官网下载rtems-4.10源码包;
然后:
tar jxvf rtems-4.10.2.tar.bz2
mkdir build-rtems
cd build-rtems
../rtems-4.10.2/configure --target=i386-rtems4.10 --enable-posix --enable-networking --enable-cxx --enable-rtemsbsp=pc386 --prefix=/opt/rtems-4.10/
make all install
一旦编译rtems没有出现错误,则说明工具链安装成功!
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。