说明
项 | 描述 |
---|---|
交叉编译 | 在当前操作平台上编译另一平台的可执行程序 |
交叉编译工具链 | 编译套件,通常可直接下载解压版使用 |
命名
命名规则:arch [-vendor] [-os] [-eabi]
例:arm-none-linux-gnueabi-gcc
项 | 描述 |
---|---|
arch | 体系架构 |
-vendor | 提供商 |
-os | 编译时的系统 |
-eabi | 嵌入式应用二进制接口 |
下载
官网
https://releases.linaro.org/components/toolchain/binaries/
https://launchpad.net/gcc-arm-embedded/+download
国内镜像
https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/_toolchains/
安装
以"arm-none-linux-gnueabi"为例完成三部曲。
1.解压
$ sudo tar -jxvf arm-2014.05-29-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 -C /opt/toolchain/
2.配置环境变量。配置文件~/.bashrc
文末加入工具链可执行文件路径:
export PATH=$PATH:/opt/toolchain/arm/3.4.1/bin
3.生效环境变量
$ source ~/.bashrc
测试
查看版本信息
$ arm-none-linux-gnueabi-gcc -v
测试编译
$ arm-none-linux-gnueabi-gcc hello.c -o hello
查看文件信息
$ 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
兼容
在64位上安装32位编译器时
$ sudo apt-get install lib32ncurses5 lib32z1