mirror of https://github.com/zeromq/pyzmq.git
Page:
Cross compiling PyZMQ for Android
1
Cross compiling PyZMQ for Android
minrk edited this page 2013-02-03 15:55:40 -08:00
Table of Contents
PyZMQ >= 13.0 should support cross-compilation to Android without any patches. Here is a step-by-step for building an android-compatible egg of pyzmq (steps taken from Issue #227).
First, if your host OS is 64b, you may need 32b compatibility libraries:
sudo apt-get install ia32-libs
Set up our root working dir (here /tmp):
export ROOT=/tmp
export ZMQ_PREFIX="$ROOT/zeromq-android"
Install the Android toolchain
cd "$ROOT"
NDK="android-ndk-r8d"
NDKTAR="$NDK-linux-x86.tar.bz2"
if [ ! -d $NDK ]; then
if [ ! -e $NDKTAR ]; then
wget -c http://dl.google.com/android/ndk/$NDKTAR
fi
tar xfj $NDKTAR
fi
sudo ./$NDK/build/tools/make-standalone-toolchain.sh --install-dir=/opt/android-toolchain
export PATH=/opt/android-toolchain/bin:$PATH
export CC="arm-linux-androideabi-gcc"
export LDSHARED="arm-linux-androideabi-gcc -shared"
Get python-lib
cd "$ROOT"
wget http://python-for-android.googlecode.com/files/python-lib_r16.zip
unzip python-lib_r16.zip -dpython-lib
Build libzmq
cd "$ROOT"
git clone git://github.com/zeromq/zeromq3-x.git
cd zeromq3-x/
./autogen.sh
./configure --host=arm-linux-androideabi --prefix="$ZMQ_PREFIX" CPPFLAGS="-fPIC -fvisibility=default" LIBS="-lgcc"
make
make install
Build pyzmq
git clone git://github.com/zeromq/pyzmq.git
cd pyzmq
echo "
[global]
zmq_prefix = $ZMQ_PREFIX
have_sys_un_h = False
[build_ext]
libraries = python2.6
library_dirs = $ROOT/python-lib/lib
include_dirs = $ROOT/python-lib/include/python2.6
[bdist_egg]
plat-name = linux-armv
" > setup.cfg
python setup.py cython
python2.6 setupegg.py build bdist_egg
And now you should have an egg in dist/pyznq-13.0dev-linux-armv.egg
, that will work on Android.
- To test it:
- install SL4A from http://android-scripting.googlecode.com/files/sl4a_r4.apk
- install python-for-android from within SL4A
- optionally create the py script to run from shell, see http://code.google.com/p/python-for-android/wiki/RunPythonFromShell and notice my comment on the version of the script I use and my environment (rooted recompiled kernel with busybox)
- run in python :
import zmq
and it works