主要參考了兩篇博文:http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html和http://wiki.woodpecker.org.cn/moin/LeoJay/HOWTOCrossCompilePythonForARMhtml
1. 交叉編譯Pythonpython
見Cross Compiling Python for Embedded Linuxlinux
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與開發板文件傳輸sql
tftp: tftp -l path/to/filename -r filename -g 192.168.*.*django
3. 文件拷貝bash
or export PATH=/your/path/bin/:$PATH # OK210開發板會報錯dom
4. 設置Python相關環境變量python2.7
以Python2.7.x爲例。ide
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測試
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1. 按照上面Paul Gibson給的Cross Compiling Python for Embedded Linux , 可是import sqlite3會報錯,緣由暫不明。
試了一些解決辦法,嘗試未果,多是lib_dir路徑問題:
3. debian平臺成功。 http://www.friendlyarm.net/forum/topic/2731
參考:
1. cross compile python, busybox, flex, bash and so on, ARM cross-compiling howto
2. 網上一個給力的例子,python-2.6.6:
Click and run python cross compiling for Embedded ARM Linux
3. 在友善之臂Linux系統中使用python http://112.124.9.243/?p=285
4. 移植python3到ARM平臺的OK6410開發板http://www.51bigfool.com/%E7%A7%BB%E6%A4%8Dpython3%E5%88%B0arm%E5%B9%B3%E5%8F%B0%E7%9A%84ok6410%E5%BC%80%E5%8F%91%E6%9D%BF.html
附:
# arm-linux-strip file
其中file是用arm-liunux-gcc編譯生成的二進制文件。
#make && make install
分類: Python