build python 2.7.11 for mips
2016-06-10 00:00
357 查看
build pgen
mkdir build.pc
cd build.pc
../configure
make Parser/pgen
因為在編譯 python 時,會用到本身的 pgen,但是 cross compile 編出來的當然不能用,只能先編一套 pc 版的出來。
$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) 改成 ./build.pc/Parser/pgen $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
configure
CC=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-gcc \
CXX=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-g++ \
STRIP=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-strip \
AR=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-ar \
RANLIB=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-ranlib \
ac_cv_file__dev_ptmx=no \
ac_cv_file__dev_ptc=no \
./configure --build=i686-pc-linux --host=mips-linux --prefix=/mnt/python --disable-ipv6
make
make install
會有些錯誤就不要理它了。
執行 /mnt/python/bin/python2.7
# /mnt/<b style="color:#000;background:#66ffff">python</b>/bin/python2.<b style="color:#000;background:#66ff99">7</b> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>>>>>>>>>[:<exec_prefix>] <b style="color:#000;background:#66ffff">Python</b> <b style="color:#000;background:#ffcc99">2</b>.<b style="color:#000;background:#66ff99">7</b>.<b style="color:#000;background:#ff66ff">11</b> (default, Jan 15 2016, 15:18:00) [GCC 4.4.<b style="color:#000;background:#66ff99">7</b>] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python27.zip', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/plat-linux2', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/lib-tk', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/lib-old', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/lib-dynload', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/site-packages'] >>>
cp ../fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/lib/libc.so.0 /mnt/python/lib
cp ../fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/lib/libm.so.0 /tftpboot/python/lib
執行前加上 export LD_LIBRARY_PATH=/mnt/python/lib 才能找到缺少的動態檔。
configure 加上 ac_cv_file__dev_ptmx=no 即可
checking for resizeterm... no configure: checking for device files 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 即可
make[1]: Leaving directory `/home/enos/FGN-1000/<b style="color:#000;background:#66ffff">Python</b>-<b style="color:#000;background:#ffcc99">2</b>.<b style="color:#000;background:#66ff99">7</b>.<b style="color:#000;background:#ff66ff">11</b>' Parser/pgen ./Grammar/Grammar Include/graminit.h <b style="color:#000;background:#66ffff">Python</b>/graminit.c Parser/pgen: Parser/pgen: cannot execute binary file make: *** [Include/graminit.h] Error 126
使用 pc 版本的 pgen 即可。
Traceback (most recent call last): File " <stdin>", line 1, in <module> File "/usr/lib/python2.<b style="color:#000;background:#66ff99">7</b>/subprocess.py", line 428, in <module> ImportError: No module named select
修改 Module/Setup,把所需要的 module 加進去重編即可。
Python交叉编译和移植
mkdir build.pc
cd build.pc
../configure
make Parser/pgen
因為在編譯 python 時,會用到本身的 pgen,但是 cross compile 編出來的當然不能用,只能先編一套 pc 版的出來。
build python
修改 Makefile.pre.in,把 pgen 換成 pc 版本。$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) 改成 ./build.pc/Parser/pgen $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
configure
CC=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-gcc \
CXX=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-g++ \
STRIP=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-strip \
AR=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-ar \
RANLIB=/home/enos/FGN-1000/fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/bin/mips-linux-ranlib \
ac_cv_file__dev_ptmx=no \
ac_cv_file__dev_ptc=no \
./configure --build=i686-pc-linux --host=mips-linux --prefix=/mnt/python --disable-ipv6
make
make install
會有些錯誤就不要理它了。
執行
把 /mnt/python 整個目錄想法子弄到 demo board 的 /mnt/python。執行 /mnt/python/bin/python2.7
# /mnt/<b style="color:#000;background:#66ffff">python</b>/bin/python2.<b style="color:#000;background:#66ff99">7</b> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>>>>>>>>>[:<exec_prefix>] <b style="color:#000;background:#66ffff">Python</b> <b style="color:#000;background:#ffcc99">2</b>.<b style="color:#000;background:#66ff99">7</b>.<b style="color:#000;background:#ff66ff">11</b> (default, Jan 15 2016, 15:18:00) [GCC 4.4.<b style="color:#000;background:#66ff99">7</b>] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python27.zip', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/plat-linux2', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/lib-tk', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/lib-old', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/lib-dynload', '/mnt/<b style="color:#000;background:#66ffff">python</b>/lib/python2.<b style="color:#000;background:#66ff99">7</b>/site-packages'] >>>
for realtek
cp ../fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/lib/libpthread.so.0 /mnt/python/libcp ../fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/lib/libc.so.0 /mnt/python/lib
cp ../fib003_res/rtl819x/toolchain/msdk-4.4.7-mips-EB-3.10-0.9.33-m32t-131227b/lib/libm.so.0 /tftpboot/python/lib
執行前加上 export LD_LIBRARY_PATH=/mnt/python/lib 才能找到缺少的動態檔。
問題排解
checking for resizeterm... no configure: checking for device files checking for /dev/ptmx... not set configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compilingconfigure 加上 ac_cv_file__dev_ptmx=no 即可
checking for resizeterm... no configure: checking for device files 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 即可
make[1]: Leaving directory `/home/enos/FGN-1000/<b style="color:#000;background:#66ffff">Python</b>-<b style="color:#000;background:#ffcc99">2</b>.<b style="color:#000;background:#66ff99">7</b>.<b style="color:#000;background:#ff66ff">11</b>' Parser/pgen ./Grammar/Grammar Include/graminit.h <b style="color:#000;background:#66ffff">Python</b>/graminit.c Parser/pgen: Parser/pgen: cannot execute binary file make: *** [Include/graminit.h] Error 126
使用 pc 版本的 pgen 即可。
Traceback (most recent call last): File " <stdin>", line 1, in <module> File "/usr/lib/python2.<b style="color:#000;background:#66ff99">7</b>/subprocess.py", line 428, in <module> ImportError: No module named select
修改 Module/Setup,把所需要的 module 加進去重編即可。
參考資料
How to cross compile python for MIPSPython交叉编译和移植
相关文章推荐
- Python3学习笔记07-特殊方法与多范式、上下文管理器、对象的属性
- Python3学习笔记08-闭包、装饰器、内存管理
- Python3学习笔记09-python常用方法总结
- Python3学习笔记10-标准库之正则、时间、路径、文件管理、存储对象
- regex pattern in python for parsing html
- Python filter()函数
- Python 进阶学习笔记1
- 一个将文件复制后以时间命名的Python程序
- ImportError: No module named 'pip'
- python with open
- python的range()函数用法
- python爬虫正方教务系统
- Python实现抓取页面上链接的简单爬虫分
- python判断文件和文件夹是否存在、创建文件夹
- django学习教程(一)如何安装python django和基本的操作
- 初试scrapy编写twitter爬虫
- python使用原始套接字 解析原始ip头数据
- leetcode之Integer Break
- Python正则表达式
- Flask--阿里云上部署