​​​​​​​build python 2.7.11 for mips

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

參考資料

 

 

 

转载于:https://my.oschina.net/activehealth/blog/689502

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值