交叉编译python2.7.7

摘要:
1、 Python下载网站:http://www.python.org/ftp/python/二、python的交叉编译依赖于openssl。openssl的下载URL为:https://www.openssl.org/source/old/三、编制:1。交叉编译openssl-1.02g#/home/sw/openssh/openssl-1.0.2g#mkdirbuild#/配置-pref

一、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
# mkdir build
#  ./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/
# make clean

(2)交叉编译python

# vi Modules/_ctypes/libffi/fficonfig.py.in 
ffi_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 Makefile
  77 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)交叉编译产生的错误及解决方法:

#make
Failed 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   #增加这一串字符

免责声明:文章转载自《交叉编译python2.7.7》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇数据加工ETL飞思卡尔XS128系列(二) PWM模块下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Python数据挖掘-词云美化

1、语料库构建 由于不像之前是对很多个文件进行词频统计,所以不需要使用os.walk()方法遍历每一个文件; 只需使用codecs.open()打开相应的文件,(记得close); 然后使用jieba模块中的load_userdict()方法导入词库 importjieba importnumpy importcodecs importpandas fi...

Linux/Unix 桌面趣事:文字模式下的 ASCII 艺术与注释绘画

boxes 命令不仅是一个文本过滤器,同时是一个很少人知道的有趣工具,它可以在输入的文本或者代码周围框上各种ASCII 艺术画。你可以用它快速创建邮件签名,或者在各种编程语言中留下评论块。这个命令可以在 vim 文本编辑器中使用,但是也可以在各种支持过滤器的文本编辑器中使用,同时也可以在命令行中单独使用。 任务: 安装 boxes 使用 apt-get 命...

在Linux中监视IO性能

dd命令 iostat命令 理解iostat的各项输出 iostat的应用实例 附:在Windows中监视IO性能 延伸阅读 dd命令 dd其实是工作于比较低层的一个数据拷贝和转换的*nix平台的工具,但是因为dd命令支持*nix平台的一些特殊设备,因此我们可以利用dd命令的这个特性来简单的测试磁盘的性能。 先说一下两个相关的特殊设备...

在Linux下执行Jmeter脚本

前言 Jmeter这款接口测试工具,已经在越来越多的公司被要求会使用了。 而且,现在应该部分小伙伴们都开始用起来了。 但是,你们知道除了在Windows用图形化界面的Jmeter执行脚本之外,还有其他可以执行的方法吗?? 今天就来告诉你们,如何在Linux服务器里执行Jmeter的jmx。 前提准备: 1.Linux下安装好JDK 2.在Windows下使...

linux重新安装python

第一步:下载python2.7  wget https://www.Python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz 第二步: 解压刚刚下载的压缩包 #tar -xvf Python-2.7.12.tar.xz 第三步:新建安装目录 mkdir /usr/local/Python27 第四步: 编译./co...

python装饰器系列(七)

装饰器 利用__call__方法实现单例 所谓单例,是指一个类的实例从始至终只能被创建一次。单例的实现有多种,这里以__call__方法来实现 1 class Single: 2 __instance = None 3 4 def __init__(self,cls): 5 self.cls = cls...