安装gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi交叉编译器

本文介绍了如何在Ubuntu 14.04 64位系统中搭建ARM交叉编译环境,包括安装必要的C开发环境工具、下载及配置Linaro提供的ARM交叉编译工具链,并验证安装成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载地址:https://www.cnblogs.com/AP0904225/p/6075816.html

1、开发平台

虚拟机:VMware 12

操作系统:Ubuntu 14.04 64bit

2、准备ARM交叉编译工具包

    编译uboot和linux kernel都需要ARM交叉工具链支持,这里使用Linaro提供的交叉编译工具。下载地址为:http://releases.linaro.org/

注意:如果主机是64bit,请选择64位的交叉编译器工具链,32bit的主机选择32位的交叉工具链。

The Linaro Toolchain Working Group is pleased to announce this quarter’s release of the Linaro Toolchain Binaries, a pre-built version of Linaro GCC and Linaro GDB that runs on generic Linux or Windows and targets the glibc Linaro Engineering Build.

Beginning 2014.11, Linaro is changing the layout and structure of its prebuilt toolchain binary releases. 2014.11 is the first release built with ABE, adding more maintainable code base and automatic testing. For further details on ABE, please visit https://wiki.linaro.org/ABE.

The folder names above describe the target triplets, i.e. the system on which you want your programs/applications to run. For more details on triplets, please click here.

Inside each folder is also a manifest.txt file further describing the target and host systems meant for the toolchain, plus source component versions.

Essentially, the main folder contents are as follows:

aarch64-linux-gnu

·        gcc-linaro-*x86_64_aarch64-linux-gnu.tar.xz

o   Linux 64-bit binaries for the Aarch64 Linux cross-toolchain

·        gcc-linaro-*i686-mingw32_aarch64-linux-gnu.tar.xz

o   Windows 32-bit binaries for the Aarch64 Linux cross-toolchain

aarch64-none-elf

·        gcc-linaro-*x86_64_aarch64-elf.tar.xz

o   Linux 64-bit binaries for the Aarch64 bare-metal cross-toolchain

·        gcc-linaro-*i686-mingw32_aarch64-elf.tar.xz

o   Windows 32-bit binaries for the Aarch64 bare-metal cross-toolchain

aarch64_be-linux-gnu

·        gcc-linaro-*x86_64_aarch64_be-linux-gnu.tar.xz

o   Linux 64-bit binaries for the Aarch64 Linux Big Endian cross-toolchain

·        gcc-linaro-*i686-mingw32_aarch64_be-linux-gnu.tar.xz

o   Windows 32-bit binaries for the Aarch64 Linux Big Endian cross-toolchain

aarch64_be-none-elf

·        gcc-linaro-*x86_64_aarch64_be-elf.tar.xz

o   Linux 64-bit binaries for the Aarch64 bare-metal Big Endian cross-toolchain

·        gcc-linaro-*i686-mingw32_aarch64_be-elf.tar.xz

o   Windows 32-bit binaries for the Aarch64 bare-metal Big Endian cross-toolchain

arm-linux-gnueabi

·        gcc-linaro-*x86_64_arm-linux-gnueabi.tar.xz

o   Linux 64-bit binaries for the ARMv7 Linux soft float cross-toolchain

·        gcc-linaro-*i686-mingw32_arm-linux-gnueabi.tar.xz

o   Windows 32-bit binaries for the ARMv7 Linux soft float cross-toolchain

arm-linux-gnueabihf

·        gcc-linaro-*x86_64_arm-linux-gnueabihf.tar.xz

o   Linux 64-bit binaries for the ARMv7 Linux hard float cross-toolchain

·        gcc-linaro-*i686-mingw32_arm-linux-gnueabihf.tar.xz

o   Windows 32-bit binaries for the ARMv7 Linux hard float cross-toolchain

arm-none-eabi

·        gcc-linaro-*x86_64_arm-eabi.tar.xz

o   Linux 64-bit binaries for the ARMv7 bare-metal cross-toolchain

·        gcc-linaro-*i686-mingw32_arm-eabi.tar.xz

o   Windows 32-bit binaries for the ARMv7 bare-metal cross-toolchain

armeb-linux-gnueabihf

·        gcc-linaro-*x86_64_armeb-linux-gnueabihf.tar.xz

o   Linux 64-bit binaries for the ARMv7 Linux Big Endian hard float cross-toolchain

·        gcc-linaro-*i686-mingw32_armeb-linux-gnueabihf.tar.xz

o   Windows 32-bit binaries for the ARMv7 Linux Big Endian hard float cross-toolchain

armeb-none-eabi

·        gcc-linaro-*x86_64_armeb-eabi.tar.xz

o   Linux 64-bit binaries for the ARMv7 bare-metal Big Endian cross-toolchain

·        gcc-linaro-*i686-mingw32_armeb-eabi.tar.xz

o   Windows 32-bit binaries for the ARMv7 bare-metal Big Endian cross-toolchain

NOTE

·        The binary source package is no longer distributed as the components are now archived at http://abe.tcwglab.linaro.org/snapshots and downloaded automatically based on manifest.txt when (re)building with ABE.

·        The source package releases for the individual components are still at http://releases.linaro.org/latest/components/toolchain. Select the component (e.g. gcc, glibc, binutils, gdb) as necessary.

·        The binary tarball has been splitted into 3 parts. As a result, you can install only the parts needed:

o   gcc-linaro-*.tar.xz – the compiler and tools

o   runtime-linaro-*.tar.xz – runtime libraries needed on the target

o   sysroot-linaro-*.tar.xz – sysroot (a set of libraries and headers to develop against)

·        Beginning 2014.11, sysroots will use the latest glibc release provided by Linaro engineers in order that users get the latest features and optimizations in the system libraries.

·        Eglibc 2.15 compatible sysroots will no longer be released. Users that require Eglibc 2.15 sysroots that need the latest Linaro GCC compiler should use the previous quarterly released sysroot.

·        x86 (32-bit) Linux host toolchains are no longer provided. x86_64 (64-bit) Linux host toolchains are provided instead.

·        Soft-float targeted toolchains are no longer supported.

 

         笔者使用的ARM交叉工具链版本为gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

下载地址为:

http://releases.linaro.org/components/toolchain/binaries/6.1-2016.08/arm-linux-gnueabi/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

 

3、安装步骤

3.1、Ubuntu14.04  64bit系统下安装标准的C开发环境

    sudo apt-get install gcc g++ libgcc1 libg++ make gdb

    或者  sudo apt-get install build-essential

3.2、下载gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

    1> 在/usr/local/文件夹下建立名为ARM-toolchain的文件夹

$ sudo mkdir /usr/local/ARM-toolchain

2> 下载gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

$ cd /usr/local/ARM-toolchain

sudo wget http://releases.linaro.org/components/toolchain/binaries/6.1-2016.08/ arm-linux-gnueabi/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

 

3.3、安装gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi

解压gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

$ xz –d gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz

tar xvf gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar

 

3.4、修改环境变量,把交叉编译器的路径加入到PATH

修改/etc/bash.bashrc文件(此文件只对当前用户适用)

$sudo gedit  /etc/bash.bashrc

然后在文件的末尾空白处加入一下代码:

# Add ARM toolschain path

if [ -d /usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi ] ; then

    PATH= /usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi/bin:"${PATH}"

fi

 

3.5、使新的环境变量生效(不用重启电脑)

    $ source /etc/bash.bashrc

 

3.6. 检查是否将路径加入到PATH:

echoechoPATH

若显示的内容中含有:/usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi/bin 说明已经将交叉编译器的路径加入PATH。

至此,交叉编译环境安装完成。

3.7. 测试是否安装成功

$ arm-linux-gnueabi-gcc -v

执行上面的命令,显示arm-linux-gnueabi-gcc -v信息和版本:

$ arm-linux-gnueabi-gcc -v

Using built-in specs.

COLLECT_GCC=arm-linux-gnueabi-gcc

COLLECT_LTO_WRAPPER=/usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi/bin/../libexec/gcc/arm-linux-gnueabi/6.1.1/lto-wrapper

Target: arm-linux-gnueabi

Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/snapshots/gcc-linaro-6.1-2016.08/configure SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libstdcxx-pch --disable-libmudflap --with-cloog=no --with-ppl=no --with-isl=no --disable-nls --enable-c99 --enable-gnu-indirect-function --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=softfp --with-mode=thumb --disable-multilib --enable-multiarch --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/sysroots/arm-linux-gnueabi --enable-lto --enable-linker-build-id --enable-long-long --enable-shared --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabi/libc --enable-languages=c,c++,fortran,lto --enable-checking=release --disable-bootstrap --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabi --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu

Thread model: posix

gcc version 6.1.1 20160711 (Linaro GCC 6.1-2016.08)

### 安装与使用 `gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabi` 编译链 对于希望在 Linux 系统上设置 ARM 架构交叉编译环境的开发者而言,`gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabi` 是一款常用的工具链。此版本适用于 64 位主机系统并用于为目标为 ARM 设备创建应用程序。 #### 下载过程 为了获取该特定版本的 GCC Linaro 工具链,可以访问官方发布的链接来下载对应的 tarball 文件: ```bash wget http://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/arm-linux-gnueabihf/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz ``` 一旦文件被成功下载至本地机器,则需对其进行解压缩操作以便后续配置和应用: ```bash xz -d gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz tar xvf gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar ``` 上述命令会将 `.tar.xz` 压缩文档转换成普通的 `.tar` 文档后再执行解压动作[^2]。 #### 设置环境变量 为了让新安装好的编译器能够在终端中直接调用而无需每次都指定完整路径,在完成解压之后应当考虑更新系统的 PATH 变量指向新的 bin 目录位置。假设已把解压后的目录放置于 `/opt/tools/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf` 中,那么可以在用户的 shell 配置文件(比如 .bashrc 或者 .zshrc)里加入如下行: ```bash export PATH=/opt/tools/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin:$PATH source ~/.bashrc # 如果是 bash 用户的话重新加载配置使更改生效 ``` 这一步骤确保了当输入诸如 `arm-linux-gnueabihf-gcc --version` 这样的命令时能够正确识别所安装的新版 GCC 编译器[^3]。 #### 关于交叉编译的概念及其应用场景 通常情况下,嵌入式设备由于资源有限或者缺乏必要的构建工具等原因并不适合在其本身之上进行软件开发工作;因此人们往往会选择在一个功能更强大的宿主平台上建立专门针对目标平台优化过的编译体系——即所谓的“交叉编译”。通过这种方式不仅可以加快迭代速度还能更好地控制最终产物的质量特性。 例如,在本案例中的ARM架构开发板上的程序确实是由更高性能的工作站或服务器端利用此类预先准备完毕的交叉编译套件来进行源代码转化而来而非直接在现场生成[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值