交叉编译环境

交叉编译环境

这里交叉编译环境指在 Ubuntu 上编译 ARM-Linux 上的可执行程序。

1. 安装交叉编译工具

下载一款 ARM 交叉编译工具

http://www.veryarm.com/arm-none-linux-gnueabi-gcc
这里写图片描述

在 Ubuntu 解压中并拷贝到指定目录

# tar -jxvf arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
# cd usr/local/ 
# cp -rv arm /usr/local/

修改环境变量

#vim /etc/bash.bashrc

在最后加上:

export PATH$PATH:/usr/local/arm/3.4.1/bin

重新加载配置文件

source ~/.bashrc

2. 测试交叉编译工具链

编写 hello.c 测试代码进行编译

long@ubuntu:~$ arm-none-linux-gnueabi-gcc hello.c -o hello

查看可执行文件信息

long@ubuntu:~$ file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped

关于更多编译工具知识,点击 http://www.veryarm.com/cross-tools

猜你喜欢

转载自blog.csdn.net/qq_37124717/article/details/81173258