i.mx287下编译和使用Python3

来源:互联网 发布:大麦盒子官网软件 编辑:程序博客网 时间:2024/06/01 11:32

    本以为开发板已经坏掉了,抱着死马当活马医的心态用风枪吹了一遍,不料竟然神奇复活了,不免感叹山寨的力量很强大。呵呵

    新产品中计划使用Python3来作为脚本语言可以实现很多动态的功能,所以必然先要将python3移植到系统中,这里记录一下准确的流程。

    参考链接:http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html

    主机环境:ubuntu-12.04

    目标环境:imx287 gcc 4.4.4

    步骤:

    1、wget -T 30 http://www.python.org/ftp/python/3.2.2/Python-3.2.2.tar.bz2

    2、tar -jxvf Python-3.2.2.tar.bz2

    3、cd Python-3.2.2

          ./configure
          make python Parser/pgen
          mv python hostpython
          mv Parser/pgen Parser/hostpgen
          make distclean

          mkdir ~/python3

    4、下载补丁:http://randomsplat.com/wp-content/uploads/2011/10/Python-3.2.2-xcompile.patch

    5、patch -p1 < Python-3.2.2-xcompile.patch

    6、CC=arm-fsl-linux-gnueabi-gcc CXX=arm-fsl-linux-gnueabi-g++ AR=arm-fsl-linux-gnueabi-ar RANLIB=arm-fsl-linux-gnueabi-ranlib ./configure --host=arm-linux --build=i686-linux-gnu --prefix=/home/llemmx/python3

    7、make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED="arm-fsl-linux-gnueabi-gcc -shared" CROSS_COMPILE=arm-fsl-linux-gnueabi- CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=i686-linux-gnu
    8、make install HOSTPYTHON=./hostpython BLDSHARED="arm-fsl-linux-gnueabi-gcc -shared" CROSS_COMPILE=arm-fsl-linux-gnueabi- CROSS_COMPILE_TARGET=yes prefix=/home/llemmx/python3

    9、将生成的软件打包下载到目标板,bin目录中的文件全部拷贝到目标板/usr/bin下,Pyhton3m目录拷贝到/usr/include/目录下,pkgconfig里面的文件拷贝到/usr/lib/pkgconfig下,删除lib文件中的 *.a文件,拷贝lib目录下的Python3.2到/usr/lib目录下

    10、vi /etc/profile 增加一行export PYTHONHOME=/usr


直接在终端运行python3能够进入即可。