Ubuntu配置嵌入式交叉编译环境
我的主机环境:
Ubuntu:11.04
uname -r:2.6.38-8-generic
uname -a:Linux hutao-ubuntu 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux
gcc -v:gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
下面介绍如何在此基础上配置嵌入式交叉编译环境:
1.
下载arm-linux-gcc-4.3.2.tgz,大约84.1M
2.
解压:
tar zxvf arm-linux-gcc-4.3.2.tgz
由于解压出后是usr/local/arm/4.3.2/...,所以把arm这个文件夹移至usr/local下:
cd usr/local
sudo mv arm /usr/local
3.
设置环境变量:
vi ~/.bashrc
加入:
export PATH=/usr/local/arm/4.3.2/bin:$PATH
注销再登录使生效
环境变量设置具体参考:http://blog.youkuaiyun.com/htttw/article/details/7220430
4.
终端:arm-linux-gcc -v
如果输出版本信息表示以上配置正确!
5.
一点说明:
编写一个hello world程序,然后:
gcc -o hello hello.c
file hello
输出:ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
用arm-linux-gcc编译:
arm-linux-gcc -o hello hello.c
file hello
输出:ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped
用arm-linux-gcc编译出的程序是无法运行在x86平台上的,只可以运行在arm上。
完成!
本文介绍在Ubuntu 11.04环境下配置嵌入式交叉编译环境的步骤,包括下载arm-linux-gcc、设置环境变量及验证配置。
1万+

被折叠的 条评论
为什么被折叠?



