一、ubuntu20.04交叉编译环境配置arm-linux-gnueabihf-gcc

在ubuntu上源码构建python,编译结果适用x86-64平台,接下来需要编译python的C代码,使之适用于arm平台,方便后续操作。

一、小讲堂

1.交叉编译

工具格式:arch [-vendor] [-os] [-(gnu)eabi]-gcc

如:gnu eabi h(hard) f(float)

二、环境/工具准备

1.python下载

版本:3.12.4

下载地址:Python Source Releases | Python.org  

//个人习惯:下载到Downloads目录,并解压缩为python-3.12.4

2.交叉编译工具链下载

sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf

不用配置环境,使用以下命令查看编译器版本

arm-linux-gnueabihf-gcc -v
arm-linux-gnueabihf-g++ -v

使用以下命令查看options

#arm-linux-gnueabihf-gcc --h
Usage: arm-linux-gnueabihf-gcc [options] file...
Options:
  -pass-exit-codes         Exit with highest error code from a phase.
  --help                   Display this information.
  --target-help            Display target specific command line options.
  --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...].
                  &n