python移植到arm_python移植到arm平台

1.  交叉编译Python

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.3make 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

or  export 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

/lib

/Python-2.7.3

Dependencies include libffi, sqlite, openssl, bzip2, zlib, etc.

1. 按照上面Paul Gibson给的Cross Compiling Python for Embedded Linux, 但是import sqlite3会报错,原因暂不明。

试了一些解决办法,尝试未果,可能是lib_dir路径问题:

Removing other search paths from the setup.py, but the one i had the ARM compiled library in, made it work. 测试也未通过。

参考:

1. cross compile python, busybox, flex, bash and so on, ARM cross-compiling howto

2. 网上一个给力的例子,python-2.6.6:

附:

用strip处理过后,将去掉其中的调试信息,执行文件大小也将小很多。命令如下:

# arm-linux-strip  file

其中file是用arm-liunux-gcc编译生成的二进制文件。

./configure --host=arm-linux CC=arm-linux-gcc AR=arm-linux-ar STRIP=arm-linux-strip RANLIB=arm-linux-ranlib

sqlite3的交叉编译

# CC=arm-linux-gcc ./configure --prefix=/your/path/sqlite-3.7.14 --host=arm-linux --disable-tcl

#make && make install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值