arm-linux-gcc交叉编译环境的搭建


方法一

l

在http://pan.baidu.com/share/link?shareid=1575352696&uk=2754759285&fid=2185900163

下载arm-linux-gcc-4.3.2.tgz.

按照如下网址推荐的做法做

http://blog.chinaunix.net/uid-26119896-id-3302233.htm



方法二
 
Ubuntu11.10搭建arm-linux-gcc-4.6.1交叉编译环境
分类: 嵌入式开发 2012-07-07 00:51 1316人阅读 评论(1) 收藏 举报
ubuntulinux内核编译器gcccommand工具

编译环境:

内核名称:Linux

内核发行版:3.0.0-12-generic

内核版本:#20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011

硬件架构名称:i686

硬件平台:i386

操作系统:GNU/Linux

当前系统gcc版本号:4.6.1

在Linux中建立整个ARM交叉编译环境的整体过程为:

1、  下载源码包

2、  建立编译目录并设置环境变量

3、  安装内核头文件

4、  安装二进制工具(binutils)

5、  建立初始编译器工具链(简版gcc)

6、  建立glibc库

7、  建立全套编译器工具链(full>
export TARGET=arm-linux

export PREFIX=$PROJECTROOT/tools

export TARGET_PREFIX=$PREFIX/$TARGET

export PATH=$PREFIX/bin:$PATH

然后设置环境变量:source>
root@ubuntu:/opt/armlinux/build-tools/build-binutils#>
cc1:>
 3)在配置时,关闭Warning报错,也可以编译成功:(我用的是这种)

[root@localhost>
参考:http://hi.baidu.com/thinke365/blog/item/0b525013fc1f095af819b853.html

 

五、建立初始编译器(简版>
“TARGET_LIBGCC2-CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix_h”

 

然后便可以切换到目录build-boot-gcc进行编译了,实例:

root@ubuntu:/opt/armlinux/build-tools/gcc-4.6.1#>
 

root@ubuntu:/opt/armlinux/build-tools/build-boot-gcc#>
libc_cv_c_cleanup=yes

libc_cv_arm_tls=yes

注:在编译过程中可能会发现本应自动生成的posix/config-name.h并没有自动生成,找不到config-name.h这个文件。这个文件是用来编译uname的。暂时没办法让它自动生成,只好自己比照uname-a的信息建一个config-name.h文件:

在build-glibc目录下建立一个posix目录

#>
root@ubuntu:/opt/armlinux/build-tools/build-glibc#>
configure:2744:>
configure:2744:>
configure:2744:>
configure:2760:>
configure:>
 

(2)[ALL ]    >
 

(10)最后,修改libc.so便完成此步骤

root@ubuntu:/opt/armlinux/build-tools/build-glibc#>
root@ubuntu:/opt/armlinux/build-tools/build-gcc# make

root@ubuntu:/opt/armlinux/build-tools/build-gcc# make install

完成之后,$PREFIX/bin下又多了几个文件:

 arm-linux-c++*

arm-linux-g++*

这些生成的文件的作用分别为:

arm-linux-g++:GNU的c++编译器

arm-linux-c++:等同于arm-linux-g++

 

八、验证

使用vim编写一个简单文件,这里以hello.c为例:

然后执行编译命令:

root@ubuntu:/opt/armlinux/tmp# arm-linux-gcc -static hello.c –o hello

编译完成后验证最终编译出的文件。实例:

root@ubuntu:/opt/armlinux/tmp# file hello

hello: ELF 32-bit LSB executable, ARM, version 1, statically linked, for GNU/Linux 2.0.0, not stripped

有如上输出表示编译ARM版本程序成功。


参考文献:http://my.oschina.net/u/225867/blog/38473


 


猜你喜欢

转载自blog.csdn.net/mzw72188552/article/details/17576777