草庐IT

安装交叉编译器 arm-linux-gnueabihf-gcc

滨边美波她男友 2023-04-12 原文

前言

在学习正点原子《ZYNQ-嵌入式Linux开发指南》第十四章 U-boot移植的时候,下载了Xlinux u-boot源码后编译,出现了错误:

root@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zynq_zc702_defconfig  
#
# configuration written to .config
#
root@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ make V=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8 # 执行make命令进行编译
make: arm-linux-gnueabihf-gcc: Command not found
/bin/sh: 1: arm-linux-gnueabihf-gcc: not found
dirname: missing operand
Try 'dirname --help' for more information.
make[1]: *** [u-boot.cfg] Error 1
  arm-linux-gnueabihf-gcc -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing  -O2    -g    -D__KERNEL__ -D__UBOOT__   -D__ARM__             -ffunction-sections -
....
/bin/sh: 1: arm-linux-gnueabihf-gcc: not found
scripts/Makefile.autoconf:80: recipe for target 'spl/u-boot.cfg' failed
make[1]: *** [spl/u-boot.cfg] Error 1
make: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'.  Stop.
root@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ 
root@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ 
root@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ arm-linux-gnueabihf-gcc -v  # 查看 arm-linux- 版本
The program 'arm-linux-gnueabihf-gcc' is currently not installed. To run 'arm-linux-gnueabihf-gcc' please ask your administrator to install the package 'gcc-arm-linux-gnueabihf'

一、下载交叉编译器

这里主要记录一下怎么下载arm-linux-gnueabi-gcc交叉编译器,这个不像其他软件一样下载最新的就是好的。不同的开发版根文件系统的版本不同,高版本的编译器编译的程序在低版本的根文件系统中不能运行。如果出现不能运行的情况有两种办法,第一将自己交叉编译器的版本降低,第二升级开发版的根文件系统。在Linaro官网中下载arm-linux-gnueabi-gcc编译器,下载网址
https://www.linaro.org/downloads/
1.新版本的下载入口如下图所示:

下载流程如下:
“GNU Toolchain Integration Builds → 11.2-2021.10-1 → arm-linux-gnueabihf → gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf.tar.xz”

二、安装交叉编译器

1.解压压缩包

zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ pwd # 当前路径
/home/zzz/xilinx_petalinux/gcc-arm-linux
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ 
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ ls -lh # gcc 压缩包文件
total 139M
-rw-r--r-- 1 zzz zzz 139M 323 14:46 gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf.tar.xz
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ tar -Jxvf gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf.tar.xz  # 解压缩
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ ls -lh
total 139M
drwxrwxrwx 8 zzz zzz 4.0K 1011 18:20 gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf
-rw-r--r-- 1 zzz zzz 139M 323 14:46 gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf.tar.xz
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ 
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ 
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ cd gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf/  # 进入解压后的目录
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ 
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ ls -lh  # 压缩包里的文件和目录
total 36K
drwxr-xr-x 7 zzz zzz 4.0K 1011 18:14 arm-linux-gnueabihf
drwxr-xr-x 2 zzz zzz 4.0K 1011 18:22 bin
-rw-r--r-- 1 zzz zzz  11K 1011 18:20 gcc-linaro-11.2.1-2021.10-linux-manifest.txt
drwxr-xr-x 3 zzz zzz 4.0K 1011 18:17 include
drwxr-xr-x 4 zzz zzz 4.0K 1011 18:22 lib
drwxr-xr-x 3 zzz zzz 4.0K 1011 17:59 libexec
drwxr-xr-x 8 zzz zzz 4.0K 1011 18:17 share
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ 

2.设置环境变量

在多人协作的服务器上,为了不影响他人的环境,最好把环境变量设置在本用户上。但是,此处依然提供两种环境变量设置的方法。

关键的两条命令: 将交叉编译器的 bin 目录和 lib 目录加入到环境变量中

export PATH=$PATH:/usr/local/arm/gcc-3.4.5-glibc-2.3.6/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/arm/gcc-3.4.5-glibc-2.3.6/lib
1)设置当前用户的环境变量
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ pwd  # 当前路径
/home/zzz/xilinx_petalinux/gcc-arm-linux/gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ 
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ ls -lh
total 36K
drwxr-xr-x 7 zzz zzz 4.0K 1011 18:14 arm-linux-gnueabihf
drwxr-xr-x 2 zzz zzz 4.0K 1011 18:22 bin
-rw-r--r-- 1 zzz zzz  11K 1011 18:20 gcc-linaro-11.2.1-2021.10-linux-manifest.txt
drwxr-xr-x 3 zzz zzz 4.0K 1011 18:17 include
drwxr-xr-x 4 zzz zzz 4.0K 1011 18:22 lib
drwxr-xr-x 3 zzz zzz 4.0K 1011 17:59 libexec
drwxr-xr-x 8 zzz zzz 4.0K 1011 18:17 share
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ 

如上所示,我们需要把 bin目录和 lib目录添加到环境变量。
在文件最后添加两行,并输入以下代码:第一行是添加执行程序的环境变量,第二行是库文件的路径。

zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ vim ~/.bashrc 
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples


export PATH=$PATH:/home/zzz/xilinx_petalinux/gcc-arm-linux/gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf/bin  # 添加 bin 目录到环境变量
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/zzz/xilinx_petalinux/gcc-arm-linux/gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf/lib        # 添加 lib 目录到环境变量                                                                                                                                                                                                                                                                                   
zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ 

保存设置,查看版本:

zzz@ubuntu-GCP1820-SS:gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf$ source ~/.bashrc # 使环境变量生效
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ 
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ arm-linux-gnueabihf-gcc -v  # 查看 arm-linux 版本
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/zzz/xilinx_petalinux/gcc-arm-linux/gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/11.2.1/lto-wrapper
Target: arm-linux-gnueabihf
....
  nfigured with: '/home/tcwg-buildslave/workspace/tcwg-gnu-build/snapshots/gcc.git~releases~gcc-。。。。
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20211011 [releases/gcc-11 revision b3dfc8635d26b9c3cbe7731dd7b8be8a2242eab9] (GCC) 
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ 
2)设置全局用户的环境变量

步骤与设置当前用户环境变量相同,只是保存的文件不再是 ./bashrc,而是 /etc/profile。

zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ sudo vi /etc/profile # 打开需要配置的文件

# 依旧是添加下面的两条命令
export PATH=$PATH:/home/zzz/xilinx_petalinux/gcc-arm-linux/gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/zzz/xilinx_petalinux/gcc-arm-linux/gcc-linaro-11.2.1-2021.10-x86_64_arm-linux-gnueabihf/lib  
zzz@ubuntu-GCP1820-SS:gcc-arm-linux$ source /etc/profile  # 使环境变量生效

3. 编译uboot

zzz@ubuntu-GCP1820-SS:~/xilinx_petalinux/u-boot-xlnx/u-boot-xlnx-xilinx-v2019.2$ ls
api   board  common     configs  doc            drivers  env       fs       Kbuild   lib       MAINTAINERS  net   README   spl   tools
arch  cmd    config.mk  disk     Documentation  dts      examples  include  Kconfig  Licenses  Makefile     post  scripts  test  u-boot.cfg
zzz@ubuntu-GCP1820-SS:~/xilinx_petalinux/u-boot-xlnx/u-boot-xlnx-xilinx-v2019.2$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zynq_zc702_defconfig
#
# configuration written to .config
#
zzz@ubuntu-GCP1820-SS:~/xilinx_petalinux/u-boot-xlnx/u-boot-xlnx-xilinx-v2019.2$ make V=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8
make: arm-linux-gnueabihf-gcc: Command not found
make -f ./Makefile syncconfig
make -f ./scripts/Makefile.build obj=scripts/basic
rm -f .tmp_quiet_recordmcount
make -f ./scripts/Makefile.build obj=scripts/kconfig syncconfig
mkdir -p include/config include/generated
....
  ./tools/mkimage -T zynqimage -R ./"" -d spl/u-boot-spl-align.bin spl/boot.bin >/dev/null  && cat /dev/null
  ./scripts/check-config.sh u-boot.cfg ./scripts/config_whitelist.txt .
zzz@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ 
zzz@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ 
zzz@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ ls -lhtr
total 11M
drwxrwxr-x  12 zzz zzz 4.0K 1024  2019 test
drwxrwxr-x   6 zzz zzz 4.0K 1024  2019 scripts
-rw-rw-r--   1 zzz zzz 177K 1024  2019 README
drwxrwxr-x   5 zzz zzz 4.0K 1024  2019 post
-rwxrwxr-x   1 zzz zzz  66K 1024  2019 Makefile
-rw-rw-r--   1 zzz zzz  19K 1024  2019 MAINTAINERS
drwxrwxr-x   2 zzz zzz 4.0K 1024  2019 Licenses
-rw-rw-r--   1 zzz zzz  18K 1024  2019 Kconfig
-rw-rw-r--   1 zzz zzz 1.9K 1024  2019 Kbuild
drwxrwxr-x   4 zzz zzz 4.0K 1024  2019 examples
drwxrwxr-x   6 zzz zzz 4.0K 1024  2019 Documentation
drwxrwxr-x  10 zzz zzz  12K 1024  2019 doc
drwxrwxr-x   2 zzz zzz  68K 1024  2019 configs
-rw-rw-r--   1 zzz zzz 2.2K 1024  2019 config.mk
drwxrwxr-x 195 zzz zzz 4.0K 1024  2019 board
drwxrwxr-x  15 zzz zzz 4.0K 1024  2019 arch
drwxrwxr-x   2 zzz zzz 4.0K 1024  2019 api
drwxrwxr-x  31 zzz zzz  16K 323 15:15 include
-rw-rw-r--   1 zzz zzz  19K 323 15:15 u-boot.cfg
-rw-rw-r--   1 zzz zzz 1.6K 323 15:15 u-boot.lds
drwxrwxr-x  17 zzz zzz  12K 323 15:15 tools
drwxrwxr-x   2 zzz zzz 4.0K 323 15:15 disk
drwxrwxr-x   2 zzz zzz 4.0K 323 15:15 env
drwxrwxr-x   5 zzz zzz 4.0K 323 15:15 common
drwxrwxr-x  13 zzz zzz 4.0K 323 15:15 fs
drwxrwxr-x   5 zzz zzz  12K 323 15:15 cmd
drwxrwxr-x   2 zzz zzz 4.0K 323 15:15 net
drwxrwxr-x  62 zzz zzz 4.0K 323 15:15 drivers
drwxrwxr-x  17 zzz zzz 4.0K 323 15:15 lib
-rw-rw-r--   1 zzz zzz 668K 323 15:15 u-boot.map
-rwxrwxr-x   1 zzz zzz 3.8M 323 15:15 u-boot
-rw-rw-r--   1 zzz zzz 170K 323 15:15 u-boot.sym
-rwxrwxr-x   1 zzz zzz 1.7M 323 15:15 u-boot.srec
-rwxrwxr-x   1 zzz zzz 552K 323 15:15 u-boot-nodtb.bin
-rw-rw-r--   1 zzz zzz  82K 323 15:15 System.map
drwxrwxr-x   2 zzz zzz 4.0K 323 15:15 dts
-rw-rw-r--   1 zzz zzz 566K 323 15:15 u-boot-dtb.bin
-rw-rw-r--   1 zzz zzz  15K 323 15:15 u-boot.dtb
-rw-rw-r--   1 zzz zzz 566K 323 15:15 u-boot.bin
-rw-rw-r--   1 zzz zzz 567K 323 15:15 u-boot-elf.o
-rwxrwxr-x   1 zzz zzz 631K 323 15:15 u-boot.elf
-rw-rw-r--   1 zzz zzz 566K 323 15:15 u-boot.img
-rw-rw-r--   1 zzz zzz 566K 323 15:15 u-boot-dtb.img
drwxrwxr-x  13 zzz zzz 4.0K 323 15:15 spl
-rw-rw-r--   1 zzz zzz 8.3K 323 15:15 u-boot.cfg.configs
zzz@ubuntu-GCP1820-SS:u-boot-xlnx-xilinx-v2019.2$ 

https://cloud.tencent.com/developer/article/1826545?from=15425
https://www.cnblogs.com/jzcn/p/14889438.html


有关安装交叉编译器 arm-linux-gnueabihf-gcc的更多相关文章

  1. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  2. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  3. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  4. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  5. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  6. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  7. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  8. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  9. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  10. ruby - 通过 RVM 安装 Ruby 1.9.2 永远行不通! - 2

    当我执行>rvminstall1.9.2时一切顺利。然后我做>rvmuse1.9.2也很顺利。但是当涉及到ruby​​-v时..sam@sjones:~$rvminstall1.9.2/home/sam/.rvm/rubies/ruby-1.9.2-p136,thismaytakeawhiledependingonyourcpu(s)...ruby-1.9.2-p136-#fetchingruby-1.9.2-p136-#downloadingruby-1.9.2-p136,thismaytakeawhiledependingonyourconnection...%Total%Rece

随机推荐