doorxp

Blog

Cross Compiling Python for IOS

Compiling python for ios platform is not difficult. Here gives some experience and steps to show how to do. Python source code version is 2.7.9

                                 

Setup Compiling Environment

  • build host version to create "Parser/pgen"

    1. ./configure  

    2. . make                 

    3.                   

  • setup environment for i386

    1. export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:/usr/local/bin:/usr/bin:/bin:$PATH"  

    2. export CFLAGS="-DIOS  -arch i386 -miphoneos-version-min=6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk"   

    3. export CXXFLAGS="$CFLAGS"  

    4. export CC="clang $CFLAGS"  

    5. export CXX="clang++ $CXXFLAGS"  

    6. export AR="ar"  

    7. export RANLIB="ranlib"  

    8. export STRIP="strip —-strip-unneeded"  

    9. export MAKE="make -j4"  

    10. export CONFIG_SITE="config.site"              

    11.                   

  • setup environment for x86_64

    1.                             

    2. export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:/usr/local/bin:/usr/bin:/bin:$PATH"  

    3. export CFLAGS="-DIOS -arch x86_64 -miphoneos-version-min=6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk"   

    4. export CXXFLAGS="$CFLAGS"  

    5. export CC="clang $CFLAGS"  

    6. export CXX="clang++ $CXXFLAGS"  

    7. export AR="ar"  

    8. export RANLIB="ranlib"  

    9. export STRIP="strip —-strip-unneeded"  

    10. export MAKE="make -j4"  

    11. export CONFIG_SITE="config.site"                  

    12.                   

  • setup environment for armv7

    1.      

    2. export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:/usr/local/bin:/usr/bin:/bin:$PATH"  

    3. export CFLAGS="-DIOS -arch armv7 -miphoneos-version-min=6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk"   

    4. export CXXFLAGS="$CFLAGS"  

    5. export CC="clang $CFLAGS"  

    6. export CXX="clang++ $CXXFLAGS"  

    7. export AR="ar"  

    8. export RANLIB="ranlib"  

    9. export STRIP="strip —-strip-unneeded"  

    10. export MAKE="make -j4"  

    11. export CONFIG_SITE="config.site"                  

    12.                   

  • setup environment for armv7s

    1.      

    2. export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:/usr/local/bin:/usr/bin:/bin:$PATH"  

    3. export CFLAGS="-DIOS -arch armv7s -miphoneos-version-min=6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk"   

    4. export CXXFLAGS="$CFLAGS"  

    5. export CC="clang $CFLAGS"  

    6. export CXX="clang++ $CXXFLAGS"  

    7. export AR="ar"  

    8. export RANLIB="ranlib"  

    9. export STRIP="strip —-strip-unneeded"  

    10. export MAKE="make -j4"  

    11. export CONFIG_SITE="config.site"                  

    12.                   

  • setup environment for arm64

    1.      

    2. export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:/usr/local/bin:/usr/bin:/bin:$PATH"  

    3. export CFLAGS="-DIOS -arch arm64 -miphoneos-version-min=6.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk"   

    4. export CXXFLAGS="$CFLAGS"  

    5. export CC="clang $CFLAGS"  

    6. export CXX="clang++ $CXXFLAGS"  

    7. export AR="ar"  

    8. export RANLIB="ranlib"  

    9. export STRIP="strip —-strip-unneeded"  

    10. export MAKE="make -j4"  

    11. export CONFIG_SITE="config.site"                  

    12.                   

         

Apply patch code

                 

Compile

  • configure for i386

    1. ./configure LDFLAGS="-Wl -L$(pwd)/../../zlib/zlib" CFLAGS="-Wno-format -I$(pwd)/zlib/zlib" --host=i386-iphone-darwin --build=x86_64-apple-darwin --prefix="$(pwd)/../../install/python279.i386" --disable-ipv6 --disable-toolbox-glue                  

    2.                   

  • configure for x86_64

    1. ./configure LDFLAGS="-Wl -L$(pwd)/../../zlib/zlib" CFLAGS="-Wno-format -I$(pwd)/zlib/zlib" --host=x86_64-iphone-darwin --build=x86_64-apple-darwin --prefix="$(pwd)/../../install/python279.x86_64" --disable-ipv6 --disable-toolbox-glue                 

    2.                   

  • configure for armv7

    1. ./configure LDFLAGS="-Wl -L$(pwd)/../../zlib/zlib" CFLAGS="-Wno-format -I$(pwd)/zlib/zlib" --host=arm-iphone-darwin --build=x86_64-apple-darwin --prefix="$(pwd)/../../install/python279.armv7" --disable-ipv6 --disable-toolbox-glue  

    2.                   

  • configure for armv7s

    1. ./configure LDFLAGS="-Wl -L$(pwd)/../../zlib/zlib" CFLAGS="-Wno-format -I$(pwd)/zlib/zlib" --host=arm-iphone-darwin --build=x86_64-apple-darwin --prefix="$(pwd)/../../install/python279.armv7s" --disable-ipv6 --disable-toolbox-glue  

    2.                   

  • configure for arm64

    1. ./configure LDFLAGS="-Wl -L$(pwd)/../../zlib/zlib" CFLAGS="-Wno-format -I$(pwd)/zlib/zlib" --host=aarch64-iphone-darwin --build=x86_64-apple-darwin --prefix="$(pwd)/../../install/python279.arm64" --disable-ipv6 --disable-toolbox-glue  

    2.                   

  • ./make

  • If there are errors, please copy "Parser/pgen" from host version, which is built in previous step

  • ./make install


发表评论:

«   2022年5月   »
1
2345678
9101112131415
16171819202122
23242526272829
3031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言

    Powered By Z-BlogPHP 1.5.1 Zero

    Copyright doorxp.com Rights Reserved.