交叉编译器

说明

描述
交叉编译在当前操作平台上编译另一平台的可执行程序
交叉编译工具链编译套件,通常可直接下载解压版使用

命名
命名规则: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

更多

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值