赵小黑 发表于 2015-4-23 10:37:27

python移植到arm平台

  主要参考了两篇博文:http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html和http://wiki.woodpecker.org.cn/moin/LeoJay/HOWTOCrossCompilePythonForARM
  1.交叉编译Python
  见Cross Compiling Python for Embedded Linux



CC=arm-linux-gcc CXX=arm-linux-g++ AR=arm-linux-ar RANLIB=arm-linux-ranlib ./configure --host=arm-linux --build=x86_64-linux-gnu --prefix=/root/tftpboot/Python-2.7.3
make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED="arm-linux-gcc -shared" CROSS_COMPILE=arm-linux- CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=x86_64-linux-gnu
make install HOSTPYTHON=./hostpython BLDSHARED="arm-linux-gcc -shared" CROSS_COMPILE=arm-linux- CROSS_COMPILE_TARGET=yes prefix=/root/tftpboot/Python-2.7.3
  2. PC与开发板文件传输
  tftp: tftp -l path/to/filename -r filename -g 192.168.*.*
  3. 文件拷贝


[*]  cp /your/path/bin/python2.7 /bin/python
   orexport PATH=/your/path/bin/:$PATH   # OK210开发板会报错


[*]       拷贝serial、django等python库拷贝到/lib/python2.7/site-packages/目录下。
  4. 设置Python相关环境变量
  以Python2.7.x为例。



export PYTHONHOME=/your/path/
#export PYTHONPATH=$PYTHONHOME:$PYTHONHOME/lib/python2.7:$PYTHONHOME/lib:$PYTHONHOME/lib/python2.7/site-packages
#export PATH=$PATH:$PYTHONHOME:$PYTHONPATH
  5. sqlite3



Building SQLLite and other dependancies
Thanks to Lothsahn’s 2.7.3 patch, it is now possible to build sqlite3, bz2, gz, ssl and ctypes.Lothsahn provides the following instructions:
To do the compilation, the dependencies must be in the include and lib folder one path up from the python install.   For example:
/include
页: [1]
查看完整版本: python移植到arm平台