您的位置:首页 > 编程语言 > Python开发

​​​​​​​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 版的出來。

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/lib

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 才能找到缺少的動態檔。

問題排解

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 compiling

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 加進去重編即可。

參考資料

How to cross compile python for MIPS

Python交叉编译和移植

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: