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/python/bin/python2.7 Could not find platform dependent libraries <exec_prefix> Consider setting &#36;PYTHONHOME to <prefix>>>>>>>>>[:<exec_prefix>] Python 2.7.11 (default, Jan 15 2016, 15:18:00) [GCC 4.4.7] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/mnt/python/lib/python27.zip', '/mnt/python/lib/python2.7', '/mnt/python/lib/python2.7/plat-linux2', '/mnt/python/lib/python2.7/lib-tk', '/mnt/python/lib/python2.7/lib-old', '/mnt/python/lib/lib-dynload', '/mnt/python/lib/python2.7/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/Python-2.7.11' Parser/pgen ./Grammar/Grammar Include/graminit.h Python/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.7/subprocess.py", line 428, in <module> ImportError: No module named select

修改 Module/Setup,把所需要的 module 加進去重編即可。

參考資料

創作者介紹

邱小新の工作筆記

台南小新 發表在 痞客邦 PIXNET 留言(0) 人氣()