Ubuntu arm 交叉编译环境搭建

  1. Linaro 官网下载:http://releases.linaro.org/components/toolchain/binaries/
    选择Linux解压版,gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar.xz
    目前我在使用(20220308):gcc-linaro-6.3.1-2017.05-i686_arm-linux-gnueabihf.tar.xz
    百度网盘链接:https://pan.baidu.com/s/1FB_kawsPtM534pp-9wnbZA
    提取码:v5hj
  2. 解压
    cd 解压目录
    xz -d gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar.xz
    tar -xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar
  3. 设置环境变量
    vi ~/.bashrc
    文件最后添加 export PATH=$PATH:解压目录/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin
    source ~/.bashrc
  4. 完了

Arm gcc 各版本的区别:

multiarch name syscall ABI instruction set endian­ness word size description spec documents
aarch64-linux-gnu linux ARMv8 little 64 aarch64 Linux Platform AAPCS64 (ARM IHI 005A)1 ELF for the ARM 64-bit Architecture2
aarch64_be-linux-gnu linux ARMv8 big 64 aarch64 Linux Platform AAPCS64 (ARM IHI 005A)1 ELF for the ARM 64-bit Architecture2
aarch64-linux-gnu_ilp32 linux ARMv8 little 32 aarch64 Linux Platform
aarch64_be-linux-gnu_ilp32 linux ARMv8 big 32 aarch64 Linux Platform
arm-linux-gnu linux ARMv7 little 32 Old ARM ABI APCS (ARM DUI 0041 chapter 9)4
arm-linux-gnueabi linux ARMv7 little 32 ARM EABI, soft-float AAPCS (ARM IHI 0042D)5 ARM GNU/Linux ABI Supplement6
arm-linux-gnueabihf linux ARMv7 little 32 ARM EABI, hard-float AAPCS (ARM IHI 0042D)5 and XXXXX (TBD)
armeb-linux-gnueabi linux ARMv7 big 32 ARM EABI, soft-float AAPCS (ARM IHI 0042D)5 ARM GNU/Linux ABI Supplement6
armeb-linux-gnueabihf linux ARMv7 big 32 ARM EABI, hard-float AAPCS (ARM IHI 0042D)5 and XXXXX (TBD)
armv8l-linux-gnueabihf linux ARMv8 little 32 ARMv8 EABI, hard-float
arm-eabi Bare-Metal ARMv7 little 32 ARM EABI, soft-float
armeb-eabi Bare-Metal ARMv7 big 32 ARM EABI, soft-float
aarch64-elf Bare-Metal ARMv8 little 64 ARMv8 EABI, hard-float
aarch64_be-elf Bare-Metal ARMv8 big 64 ARMv8 EABI, hard-float

问题1:执行 arm-linux-gnueabihf-gcc -v 报错
arm-linux-gnueabihf-gcc: cannot execute binary file: Exec format error
原因1:arm-linux-gnueabihf-gcc 32位,系统Ubuntu 64位
解决1:更换32位Ubuntu系统

20220303备忘:
项目使用了c++11标准以及boost库,arm交叉编译工具链版本从4.9升级至6.3