2.73 交叉编译python_交叉编译python2.7.7

本文详细介绍了如何在Linux环境下交叉编译Python 2.7.7,适用于AARCH64架构。首先,你需要下载Python源码和依赖的openssl库。然后,按照指定的配置选项编译openssl和Python,包括设置prefix、host、build参数以及处理编译过程中遇到的各种错误,如getaddrinfo函数、ipv6、ptmx和ptc设备文件问题。文章还提供了解决编译Parser/pgen模块错误的方法,并给出了在Makefile中修改LDFLAGS以链接openssl库的步骤。
摘要由CSDN通过智能技术生成

一、python下载网址: http://www.python.org/ftp/python/

二、python的交叉编译依赖openssl ,openssl的下载网址: https://www.openssl.org/source/old/

三、编译:

1、交叉编译 openssl-1.0.2g

# /home/sw/openssh/openssl-1.0.2g

#mkdirbuild

# ./config --prefix=/home/sw/openssh/old/openssl-1.0.2g/build os/compiler:aarch64-linux-gnu-gcc -fPIC

#make#make -i install

2、交叉编译python

# tar -xvf Python-2.7.7.tar.xz

# cd Python-2.7.7

# mkdir arm_build (存放交叉编译的信息)

# mkdir local_build (存放本地编译的信息)

# cd Python-2.7.7/

(1)首先本地编译pgen

# ./configure --prefix=/home/carrie/python/Python-2.7.7/local_build/#make#make install#cp Parser/pgen arm_build/#makeclean

(2)交叉编译python

# vi Modules/_ctypes/libffi/fficonfig.py.inffi_platforms={'AARCH64': ['src/aarch64/ffi.c', 'src/aarch64/sysv.S'], ##增加这一行'MIPS_IRIX': ['src/mips/ffi.c', 'src/mips/o32.S', 'src/mips/n32.S'],

# ./configure --prefix=/Python-2.7.7/arm_build/ --host=aarch64-linux-gnu --build=x86_64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-ar LD=aarch64-linux-gnu-ld ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no --disable-ipv6

# vim Makefile77 LDFLAGS=-L/home/sw/openssh/old/openssl-1.0.2g/build/lib#找到LDFLAGS,在LDFLAGS后面增加这一串字符

#make#make -i install

四、编译过程中遇到的错误:

(1)#./configure --prefix=/home/python/Python-2.7.7/build/ --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-ar --without-gcc

checking build system type... x86_64-unknown-linux-gnu

checking host system type... aarch64-unknown-linux-gnu

configure: error: Cross compiling required --host=HOST-TUPLE and --build=ARCH

原因:缺少--build的设置

解决方法:#./configure 后面加上 "--build=x86_64-linux-gnu "

(2)#./configure --prefix=/home/python/Python-2.7.7/build/ --host=aarch64-linux-gnu --build=x86_64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-ar --without-gcc

Fatal: You must get working getaddrinfo() function.

or you can specify "--disable-ipv6".

解决方法:./configure 后面加上 "--disable-ipv6"

(3)# ./configure --prefix=/home/python/Python-2.7.7/build/ --host=aarch64-linux-gnu --build=x86_64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-ar --disable-ipv6

checking for /dev/ptmx... not set

configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling

解决方法: ./configure后面加上 "ac_cv_file__dev_ptmx=no"

(4)#./configure --prefix=/home/python/Python-2.7.7/build/ --host=aarch64-linux-gnu --build=x86_64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-ar --disable-ipv6 ac_cv_file__dev_ptmx=no

checking for /dev/ptc... not set

configure: error: set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling

解决方法:./configure后面加上 "ac_cv_file__dev_ptc=no"

(5)编译出错:

# make

make[1]: Leaving directory '/home/python/Python-2.7.7'

Parser/pgen ./Grammar/Grammar Include/graminit.h Python/graminit.c

Parser/pgen: 1: Parser/pgen: Syntax error: "(" unexpected

Makefile:616: recipe for target 'Include/graminit.h' failed

make: *** [Include/graminit.h] Error 2

解决方法:编译Parser/pgen :

# ./configure

# make python Parser/pgen

# cp Parser/pgen build/Parser/

(6)交叉编译产生的错误及解决方法:

#makeFailed to build these modules:

_bisect _codecs_cn _codecs_hk

_codecs_iso2022 _codecs_jp _codecs_kr

_codecs_tw _collections _csv

_ctypes _ctypes_test _elementtree

_functools _hashlib _heapq

_hotshot _io _json

_locale _lsprof _multibytecodec

_multiprocessing _random _socket

_ssl _struct _testcapi

array audioop binascii

cmath cPickle crypt

cStringIO datetime fcntl

future_builtins grp itertools

math mmap nis

operator parser pyexpat

resource select spwd

strop syslog termios

time unicodedata

running build_scripts

解决方法:

# vim Makefile

77 LDFLAGS= -L/home/sw/openssh/old/openssl-1.0.2g/build/lib   #增加这一串字符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值