ubuntu 12.10搭建RTEMS开发环境(源码包编译)

来源:互联网 发布:莽牯朱蛤 知乎 编辑:程序博客网 时间:2024/06/05 04:41

1.从此处下载工具包(http://pan.baidu.com/share/link?shareid=175509&uk=336267398);

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:(若没有安装texinfo,要先安装texinfo,否则出现错误)

    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}

然后注销重新登录使修改生效

6.安装gcc:

由于gcc的安装依赖gmp和mpfr,gmp又依赖m4,因此首先安装m4、gmp和mpfr:(下载地址:ftp://ftp.gnu.org/gnu/)

安装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没有出现错误,则说明工具链安装成功!


8.最后在/etc/bash.bashrc中添加export RTEMS_MAKEFILE_PATH=/opt/rtems-4.10/i386-rtems/pc386,指定rtems makefile引用文件位置,然后注销重新登录使其生效.

下面就可以编译rtems应用程序了.

   


原创粉丝点击