Luajit 64-bit for COCOS2DX compiling iOS workaround

Source: Internet
Author: User

Recently Luajit released the 64-bit beta version, because AppStore on-line must be a 64-bit app, and my game project uses LUA scripts, so you have to use the 64-bit Luajit to compile the Lua script.

Here's how:

Download Luajit source code at LUAJIT website:

http://luajit.org

After decompression, you need to go through the Luajit folder in the upper directory, open the terminal compile, compile the following command:

Luajit=./luajit-2.1.0-beta2

Devdir= ' Xcode-select-print-path '/platforms

Iosver=iphoneos9.3.sdk

Simver=iphonesimulator.sdk

iosdir= $DEVDIR/iphoneos.platform/developer

simdir= $DEVDIR/iphonesimulator.platform/developer

Iosbin= $DEVDIR/.. /toolchains/xcodedefault.xctoolchain/usr/bin/

simbin= $SIMDIR/usr/bin/

build_dir= $LUAJIT/build

RM-RF $BUILD _dir

Mkdir-p $BUILD _dir

RM *.a 1>/dev/null 2>/dev/null

Echo =================================================

Echo ARMV7 Architecture

isdkf= "-arch armv7-isysroot $IOSDIR/sdks/$IOSVER"

Make-j-C $LUAJIT host_cc= "Gcc-m32" cross= $IOSBIN target_flags= "$ISDKF" target=armv7 target_sys=ios clean

Make-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.a

Echo =================================================

Echo ARM64 Architecture

isdkf= "-arch arm64-isysroot $IOSDIR/sdks/$IOSVER"

Make-j-C $LUAJIT host_cc= "gcc" cross= $IOSBIN target_flags= "$ISDKF" target=arm64 target_sys=ios clean

Make-j-C $LUAJIT host_cc= "gcc" cross= $IOSBIN target_flags= "$ISDKF" target=arm64 Target_sys=ios

MV $LUAJIT/src/libluajit.a $BUILD _dir/libluajit64bit.a

Echo =================================================

echo IOS Simulator Architecture

isdkf= "-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 clean

Make-j-C $LUAJIT host_cflags= "-arch x86_64" host_ldflags= "-arch x86_64" Target_sys=ios target=x86_64 amalg CROSS= $IOSBI N target_flags= "$ISDKF"

MV $LUAJIT/src/libluajit.a $BUILD _dir/libluajitx86_64.a

Libtool-o $BUILD _dir/libluajit21.a $BUILD _dir/*.a 2>/dev/null

Mkdir-p $BUILD _dir/headers

CP $LUAJIT/src/lua.h $BUILD _dir/headers

CP $LUAJIT/src/lauxlib.h $BUILD _dir/headers

CP $LUAJIT/src/lualib.h $BUILD _dir/headers

CP $LUAJIT/src/luajit.h $BUILD _dir/headers

CP $LUAJIT/SRC/LUA.HPP $BUILD _dir/headers

CP $LUAJIT/src/luaconf.h $BUILD _dir/headers

MV $BUILD _dir/libluajit21.a./

Note that the Iosver variable above must be set to the version number of the iOS SDK for the current system.

After compiling, in the Luajit folder will be added to the build folder, there are three libraries and headers folder, headers inside

Contains the header files that the project must contain, plus three libraries. A library:

LIBLUAJIT64BIT.A: is an arm 64-bit library, used on iOS 64-bit devices,

LIBLUAJITA7.A: is an arm 32-bit library, used on iOS 32-bit devices,

LIBLUAJITX86_64: is a library of x86 instructions for use on the PC and iOS simulator.

Import the library and all header files for the corresponding platform into the bytecode used to parse the Luajit in the project.

Because the virtual machines above iphone5s need x86_64 support, Luajit to support this mode requires additional parameters in the other linker flags (note that only the emulator needs to be added, not for iOS, or Apple will not be audited):

-pagezero_size 10000-image_base 100000000

Because Arm64 uses the latest C libraries for LJ_GC64 and LJ_FR2, LUA scripts must be compiled from the GC64 library, so we need to compile on the real machine, or

Luajit source, locate the Lj_arch.h file, add macros at the beginning of the file:

#define LUAJIT_ENABLE_GC64 to compile using the GC64 bit library when compiling.

The following code is my compilation method in Liao Capital, in fact, the Lua script is placed under the source folder,

Use Lua's string.dump to turn the script into the bytecode of the corresponding platform, and then export the compiled

Byte code, concrete implementation see compile Project Main.lua, I will compile the project into Baidu Cloud Disk (upload ....) ), easy to download,

Project compilation can be compiled on an iOS emulator or on a real machine, and if the real machine is not jailbroken, it can be compiled via FTP

Lua script to the FTP server, it is also more convenient to compile on the iOS emulator, and then find the compiled script in the writable path, compile and copy the script to

Work perfectly in your own project.

Note that if the function Main.lua cannot pass

Executescriptfile method execution, must be performed through require Main.lua

Reprint please indicate the source, from the blog Park Hemjohn

Luajit 64-bit for COCOS2DX compiling iOS workaround

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.