交叉编译Python-3.8.3

源码下载

​wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz

xz-d Python-3.8.3.tar.xz

tar -xvf Python-3.8.3.tar.xz

cd Python-3.8.3

​


如果PC上预先没有python3.8的版本,则需要编译3.8的PC版本

执行:mkdir build.pc; cd build.pc; ../configure --enable-optimizations; make

将编译的PC版本安装的本地PC,为了不影响PC上原来python的使用,此处直接使用软链接的形式完成安装,ln -s /python3.8 /usr/bin/python(一般而言,python可执行文件位于/usr/bin/目录下)

测试:运行python,结果如下则说明安装成功:

Python 3.8.3 (default, Jun  4 2020, 16:27:05) 
[GCC 6.5.0 20181026] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

交叉编译

mkdir build.arm

../configure \
    --prefix=/Python-3.8.3 \
    --build=aarch64-linux-gnu \
    --host=aarch64-linux \
    --target=aarch64-linux-gnu \
    --enable-shared \
    --enable-ipv6 \
    --with-system-ffi \
    ac_cv_file__dev_ptmx=0 \
    ac_cv_file__dev_ptc=0 \
    --enable-optimizations

make; make install

交叉编译报错

checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.8... no
checking for python3... python3
checking for python interpreter for cross build... configure: error: python3.8 interpreter not found

上面主要报错原因是本地PC上无3.8的python版本,按照步骤2的方法即可解决该问题。

你可能感兴趣的:(Linux,python)