Luajit2.1 64-bit compilation and general library for iOS, luajit2.1ios

Source: Internet
Author: User

Luajit2.1 64-bit compilation and general library for iOS, luajit2.1ios
Apple requires that the old app support 64-bit after March, and the new app must support 64-bit since 2.1. We use luajit, while luajit2.0.x only supports 32bit. 64-bit is supported in version 2.1, but only alpha is supported currently. The following luajit Library supports arm64, armv7, and Simulators after compilation. That is, a library supports 64-bit compilation of all CPUs and does not need to be specially processed for new and old iPhones.

Download LuaJit download Luajit code through GIT

git clone http://repo.or.cz/luajit-2.0.git
Go to the Luajit download code directory and check out the branch v2.1
git checkout v2.1

Compile scriptsRun in the upper-level directory of the luajit-2.0
LUAJIT=./luajit-2.1DEVDIR=`xcode-select -print-path`/PlatformsIOSVER=iPhoneOS8.1.sdkSIMVER=iPhoneSimulator.sdkIOSDIR=$DEVDIR/iPhoneOS.platform/DeveloperSIMDIR=$DEVDIR/iPhoneSimulator.platform/DeveloperIOSBIN=$DEVDIR/../usr/bin/SIMBIN=$SIMDIR/usr/bin/BUILD_DIR=$LUAJIT/buildrm -rf $BUILD_DIRmkdir -p $BUILD_DIRrm *.a 1>/dev/null 2>/dev/nullecho =================================================echo ARMV7 ArchitectureISDKF="-arch armv7 -isysroot $IOSDIR/SDKs/$IOSVER"make -j -C $LUAJIT HOST_CC="gcc -m32 " CROSS=$IOSBIN TARGET_FLAGS="$ISDKF" TARGET=armv7 TARGET_SYS=iOS cleanmake -j -C $LUAJIT HOST_CC="gcc -m32 " CROSS=$IOSBIN TARGET_FLAGS="$ISDKF" TARGET=armv7 TARGET_SYS=iOS mv $LUAJIT/src/libluajit.a $BUILD_DIR/libluajitA7.aecho =================================================echo ARM64 ArchitectureISDKF="-arch arm64 -isysroot $IOSDIR/SDKs/$IOSVER"make -j -C $LUAJIT HOST_CC="gcc " CROSS=$IOSBIN TARGET_FLAGS="$ISDKF" TARGET=arm64 TARGET_SYS=iOS cleanmake -j -C $LUAJIT HOST_CC="gcc " CROSS=$IOSBIN TARGET_FLAGS="$ISDKF" TARGET=arm64 TARGET_SYS=iOS mv $LUAJIT/src/libluajit.a $BUILD_DIR/libluajit64bit.aecho =================================================echo IOS Simulator ArchitectureISDKF="-arch x86_64 -isysroot $SIMDIR/SDKs/$SIMVER -miphoneos-version-min=7.0"make -j -C $LUAJIT HOST_CFLAGS="-arch x86_64" HOST_LDFLAGS="-arch x86_64" TARGET_SYS=iOS TARGET=x86_64 cleanmake -j -C $LUAJIT HOST_CFLAGS="-arch x86_64" HOST_LDFLAGS="-arch x86_64" TARGET_SYS=iOS TARGET=x86_64 amalg CROSS=$SIMBIN TARGET_FLAGS="$ISDKF"mv $LUAJIT/src/libluajit.a $BUILD_DIR/libluajitx86_64.alibtool -o $BUILD_DIR/libluajit21.a $BUILD_DIR/*.a 2> /dev/nullmkdir -p $BUILD_DIR/Headerscp $LUAJIT/src/lua.h $BUILD_DIR/Headerscp $LUAJIT/src/lauxlib.h $BUILD_DIR/Headerscp $LUAJIT/src/lualib.h $BUILD_DIR/Headerscp $LUAJIT/src/luajit.h $BUILD_DIR/Headerscp $LUAJIT/src/lua.hpp $BUILD_DIR/Headerscp $LUAJIT/src/luaconf.h $BUILD_DIR/Headersmv $BUILD_DIR/libluajit21.a ../lib/ios


Note: when compiling the simulator Library: ISDKF = "-arch x86_64-isysroot $ SIMDIR/SDKs/$ SIMVER-miphoneos-version-min = 7.0"
The above section is mainly used to compile the luajit library of the simulator. Because of the changes made after xcode5.0, you must use this method to specify the compilation as the simulator Library; otherwise, the default compilation is macos. I have been here for a long time.
Integration
Link libluajit21.a under the luajit/build directory to the project.

Because the iPhone 5s and above VMS require x86_64 support, luajit needs to add parameters in other linker flags to support this mode (Note: you only need to add parameters to the simulator, but cannot add parameters for ios, otherwise, apple will not pass the review)

-pagezero_size 10000 -image_base 100000000

Possible traps

1: currently, luajit 2.1 is only an alpha version. Is there any major bug unclear?

2: the bytecode of luajit on the arm64 platform is different from the previous bytecode. It cannot be compiled on the mac and used on the arm64 platform. It uses the latest lj_gc64 and lj_fr2. Therefore, the lua Code Compiled directly under macos cannot be run on ios. Source code needs to be uploaded and compiled in ios



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.