回页首
建立全套编译器(full gcc)
在建立boot-gcc 的时候,我们只支持了C。到这里,我们就要建立全套编译器,来支持C和C++。
$cd $PRJROOT/build-tools/build-gcc
$../gcc-2.95.3/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++
--enable-languages=c,c++ 告诉 full gcc 支持 c 和 c++ 语言。
然后编译和安装你的 full gcc
$make all
$make install
我们再来看看 $PREFIX/bin 里面多了哪些东西
$ls $PREFIX/bin
你会发现多了 arm-linux-g++ 、arm-linux-protoize 和 arm-linux-c++ 几个文件。
G++-gnu的 c++ 编译器。
Protoize-与Unprotoize相反,将K&R C的源码转化为ANSI C的形式,函数原型中加入参数类型。
C++-gnu 的 c++ 编译器。
到这里你的交叉编译工具就算做完了,简单验证一下你的交叉编译工具。
用它来编译一个很简单的程序 helloworld.c
#include <stdio.h>
int main(void)
{
printf("hello world\n");
return 0;
}
$arm-linux-gcc helloworld.c -o helloworld
$file helloworld
helloworld: ELF 32-bit LSB executable, ARM, version 1,
dynamically linked (uses shared libs), not stripped
上面的输出说明你编译了一个能在 arm 体系结构下运行的 helloworld,证明你的编译工具做成功了。
 回页首
参考资料
- Wookey ,Chris Rutter, Jeff Sutherland, Paul Webb ,《The GNU Toolchain for ARM Target HOWTO》
- Karim Yaghmour,《Building Embedded Linux Systems》,USA:O'Reilly,2003
(出处:清风网络学院)
上一篇:小心借情人节传播的QQ尾巴(第3版)
下一篇:对软件项目管理的探讨
|