下载python3.2.2,高版本的没有找到交叉编译的补丁
1. 解压:tar xzvf python3.2.2.tar.gz
2. cd python3.2.2
3. 配置: ./configure
编译PC版python Parser/pgen: make python Parser/pgen
将生成的PC版移动到hostpython: mv python hostpython
将生成的PC版解释器移动至Parser/hostpgen: mv Parser/pgen Parser/hostpgen
清除不必要的文件 : make distclean
打补丁: patch -p1 <python-3.2.2-xcompile.patch
./configure --host=arm-linux --build=x86_64-linux-gnu --prefix=/python
CC=arm-arago-linux-gnueabi-gcc CXX=arm-arago-linux-gnueabi-g++ AR=arm-arago-linux-gnueabi-ar RANLIB=arm-arago-linux-gnueabi-ranlib ./configure --host=arm-arago-linux-gnueabi --prefix=/python make
make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED="arm-arago-linux-gnueabi-gcc -shared" CROSS_COMPILE=arm-arago-linux-gnueabi- CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=x86_64-linux-gnu
make install HOSTPYTHON=./hostpython BLDSHARED="arm-arago-linux-gnueabi-gcc -shared" CROSS_COMPILE=arm-arago-linux-gnueabi- CROSS_COMPILE_TARGET=yes prefix=/home/cpf/work/test/python-3.2.2/install
将目录打包/home/cpf/work/test/python-3.2.2/install,拷贝到开发板
创建目录/python,将压缩包解压到这个目录
修改配置
PYTHONHOME=/python 为刚刚创建的目录,放置python编译好的文件
vi /etc/profile
USER="`id -un`"
LOGNAME=$USER
PS1='[$USER@$HOSTNAME]# '
PYTHONHOME=/python
PATH=$PYTHONHOME/bin:$PATH
HOSTNAME=`/bin/hostname`
export USER LOGNAME PS1 PATH PYTHONHOME
source /etc/profile