Re: cross compile luajit for iOS 7

  • From: "Raymond W. Ko" <raymond.w.ko@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 03 Feb 2014 10:16:18 -0500

I was encountering the same problem. Luckily, I could hack to together the below script to make a armv7 and armv7s fat library of libluajit.a which works on iOS.


arm64 fails to compile as an unrecognized platform. Not sure if there is even any interest in porting as you can't even get JIT on iOS, and no mainstream Android mobile device has ARM64 anyways.

#!/bin/bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"

rm -rf include
rm -rf lib
mkdir -p include
mkdir -p lib

# download
mkdir -p src
cd src
if [ ! -d "luajit-2.0" ]
then
  git clone http://luajit.org/git/luajit-2.0.git
fi

cd luajit-2.0
# v2.1 generate bad JIT code and causes a crash on Windows
#git checkout v2.1

IXCODE=`xcode-select -print-path`
ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
ISDKVER=iPhoneOS7.0.sdk


  ISDKP=/usr/bin/

ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
make clean
make HOST_CC="xcrun gcc -m32 -arch i386" CROSS="$ISDKP" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
cp src/libluajit.a ../../lib/libluajit_arm7.a

ISDKF="-arch armv7s -isysroot $ISDK/SDKs/$ISDKVER"
make clean
make HOST_CC="xcrun gcc -m32 -arch i386" CROSS="$ISDKP" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
cp src/libluajit.a ../../lib/libluajit_arm7s.a

#ISDKF="-arch arm64 -isysroot $ISDK/SDKs/$ISDKVER"
#make clean
#make HOST_CC="xcrun gcc -m32 -arch i386" CROSS="$ISDKP" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
#cp src/libluajit.a ../../lib/libluajit_arm64.a

# copy includes
cp src/lua.hpp ../../include/

cp src/lauxlib.h ../../include/
cp src/lua.h ../../include/
cp src/luaconf.h ../../include/
cp src/lualib.h ../../include/
cp src/luajit.h ../../include/

# combine lib
cd ../../lib
lipo -create -output libluajit.a libluajit_arm7.a libluajit_arm7s.a


Hello LuaJIT experts!
I’m planning to return to Lua after five years of absents. We’re working on an
iOS 7 based collaborative multimedia app and have huge difficulties to cross
compile LuaJIT for the new iOS 7 toolchain. Apple have removed the gcc
entirely, as it appears, from the toolchain. I believe the path tree for
various command line tools have moved too. Is there anyone on this list who has
succeeded in cross compiling LuaJIT for iOS devises (32bit and 64bit) and who’d
like to share their experience? Thank you in advance!

Regards
Rikard Lindell, phd
C3N performance
http://c3n.se


Other related posts: