编译用于Android的Python

CC=armv7a-linux-androideabi28-clang
CXX=armv7a-linux-androideabi28-clang++
CONFIGURE="--host=arm-linux-androideabi"
CONFIGURE+=" --build=x86_64-linux-gnu"
CONFIGURE+=" --enable-optimizations"
CONFIGURE+=" --disable-ipv6"
CONFIGURE+=" ac_cv_file__dev_ptmx=no"
CONFIGURE+=" ac_cv_file__dev_ptc=no"
./configure $CONFIGURE
make
PYTHONHOME
|   bin
|   lib
    |   python3.8
        |   lib-dynload

将编译生成的python文件复制到bin目录,将Lib目录中的文件复制到python3.8目录,将build/lib.linux-arm-3.8目录中的文件复制到lib-dynload目录。

注:如果编译目标架构是arm64可能在加载需要动态链接库的模块(例如math)时出现"cannot locate symbol "__start___llvm_prf_vnds"的错误。这有可能是NDK的bug(https://github.com/android/ndk/issues/1103)。

原文地址:https://www.cnblogs.com/JebediahKerman/p/12851119.html