2
votes

Does anyone know the correct flags to pass to make in order to cross compile LuaJIT for the iOS Simulator? I managed to get it running on a device, but I am having trouble building for the simulator, I can't find a working example anywhere on the webs.

Thanks!!

Inside LuaJIT checkout (I'm using v2.1 branch):

IXCODE=`xcode-select -p`
ISDK=$IXCODE/Platforms/iPhoneSimulator.platform/Developer
ISDKVER=iPhoneSimulator8.1.sdk
ISDKP=/usr/bin/
ISDKF="-arch i386 -isysroot $ISDK/SDKs/$ISDKVER"

make clean
make HOST_CFLAGS="-arch i386" HOST_LDFLAGS="-arch i386" TARGET=x86 CROSS=$ISDKP TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS

This is the error message I am getting:

ld: building for MacOSX, but linking against dylib built for iOS Simulator file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/usr/lib/libSystem.dylib' for architecture i386

Building for armv7 works:

IXCODE=`xcode-select -p`
ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
ISDKVER=iPhoneOS8.1.sdk
ISDKP=/usr/bin/
ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"

make clean
make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
1
Run it in a debugger and see what line it fails on? Also you may need to wrap your TARGET_FLAGS in quotes. - Colonel Thirty Two
Returned L is NULL. I don't know if it is relevant, but LuaJIT's installation manual tells that OSX-64 target must be linked with -pagezero_size 10000 -image_base 100000000. If you get this error from an iPhone simulator, that may be the case. - user3125367
@user3125367 L is NULL indeed, thanks!! It turns out that the problem is only with the simulator architecture, it works on the phone, so I am going to edit my post to reflect this. - naartjie

1 Answers

0
votes

add -mios-simulator-version-min=8.1 to your TARGET_FLAGS

ISDKF="-arch i386 -isysroot $ISDK/SDKs/$ISDKVER"

should be

ISDKF="-arch i386 -mios-simulator-version-min=8.1 -isysroot $ISDK/SDKs/$ISDKVER"

you may also have to set the

BUILDMODE="static"

and you may need to set ios-simulator-version-min to match the simulator sdk version. 8.2 is for Xcode 6.2.