ARM交叉编译工具

什么是交叉编译工具?

交叉编译就是指在一种平台架构上编译在另外一种平台体系架构运行的程序。常见的是在X86的服务器上编译ARM linux的程序,或者windows环境下编译ARM MCU的程序。

交叉编译工具链是一套综合开发工具,包括编译器、链接器等其他辅助工具。平时工作一般不会要求自己制作交叉编译工具,会使用厂商提供的现成的(编译过程相对复杂,可以参考buildroot)。

 

这次碰到的问题是在使用aarm64-none-elf-gcc编译linux的应用程序时报错:

/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/crt0.o: In function `_start':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/libgloss/aarch64/crt0.S:148: undefined reference to `initialise_monitor_handles'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-exit.o): In function `exit':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/stdlib/exit.c:70: undefined reference to `_exit'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-writer.o): In function `_write_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/writer.c:58: undefined reference to `_write'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/lseekr.c:58: undefined reference to `_lseek'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-openr.o): In function `_open_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/openr.c:59: undefined reference to `_open'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-readr.o): In function `_read_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/readr.c:58: undefined reference to `_read'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-closer.o): In function `_close_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/closer.c:53: undefined reference to `_close'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/fstatr.c:62: undefined reference to `_fstat'
/opt/plnx/plnx-v17.3/tools/linux-i386/aarch64-none-elf/bin/../aarch64-none-elf/libc/usr/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
/proj/esdt_sdk/gnu_abe/ABE/builds/lin/arm/arm-none-eabi/snapshots/newlib-newlib-2_4_0/newlib/libc/reent/isattyr.c:58: undefined reference to `_isatty'
 

在网上找了很久资料也没有答案。后来才发现这个编译工具只是用来编译uboot的代码,编译应用程序需要用aarch64-linux-gnu-gcc。为了搞清楚两者的区别查了一些资料做一下记录。

分类和说明

从授权商,分为免费授权版和付费授权版。

免费版目前有三大主流工具商提供,第一是GNU,第二是 Codesourcery ,第三是Linaro

收费版有ARM原厂提供的armcc,IAR(编译MCU的综合编译环境)提供的编译器等等,这些往往收费较贵。像IAR这类集成工具可以下载破解版使用。

命名规则

交叉编译工具链的命名规则为:arch [-vendor] [-os] [-(gnu)eabi]

· arch - 体系结构,如ARM,MIPS,PPC

· vendor - 工具链提供商

· os - 目标操作系统

· eabi - 嵌入式应用二进制接口(embedded application binary interface)

示例

1、arm-none-eabi-

(ARM architecture, no vendor, not target an operation system,complies with the ARM EABI)

用于编译ARM架构的裸机系统(包括ARM的uboot、kernel),不能编译linux系统的应用程序。

2、arm-none-linux-gnueabi-

(ARM architecture,no vendor,creates binaries that run no the Linux peration system, and use the GNU EABI)

ARM架构的linux系统,可用于编译ARM架构的uboot、kernel,应用程序等。arm-none-linux-gnueabi-基于GCC,使用Glibc库,经过Codesourcery公司优化推出的编译器。

3、arm-eabi-

android ARM编译器

4、arm-none-uclinuxeabi-gcc

使用uclibc的C库

 

Reference:

https://blog.csdn.net/haly321/article/details/54599266

你可能感兴趣的:(ARM交叉编译工具)