今天更新luajit2.1beta2時,編譯android一直報錯。
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found make[1]: /Users/apple/android/android-ndk-r10c//toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-clang: Command not found Makefile:264: *** Unsupported target architecture. Stop. make: *** [default] Error 2閱讀最src/Makefile發現增加了這麼一句
ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) HOST_SYS= Windows HOST_RM= del else HOST_SYS:= $(shell uname -s) ifneq (,$(findstring MINGW,$(HOST_SYS))) HOST_SYS= Windows HOST_MSYS= mingw endif ifneq (,$(findstring CYGWIN,$(HOST_SYS))) HOST_SYS= Windows HOST_MSYS= cygwin endif # Use Clang for OSX host. ifeq (Darwin,$(HOST_SYS)) DEFAULT_CC= clang endif endif在mac下編譯默認用的clang, NDK是沒有i686-linux-android-clang,
修改成默認gcc做了一個判斷
# Use Clang for OSX host. ifeq (Darwin,$(HOST_SYS)) ifneq (Linux, $(TARGET_SYS)) DEFAULT_CC= clang endif endif貼上 luajit 編譯代碼
#!/bin/sh DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" host_os=`uname -s | tr "[:upper:]" "[:lower:]"` SRCDIR=$DIR/src cd "$SRCDIR" NDK=$NDK_ROOT NDKABI=8 NDKVER=$NDK/toolchains/arm-linux-androideabi-4.9 NDKP=$NDKVER/prebuilt/${host_os}-x86_64/bin/arm-linux-androideabi- NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm" # Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo) DESTDIR=$DIR/prebuilt/android/armeabi rm "$DESTDIR"/*.a make clean make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_SYS=Linux TARGET_FLAGS="$NDKF" if [ -f $SRCDIR/src/libluajit.a ]; then mv $SRCDIR/src/libluajit.a $DESTDIR/libluajit.a fi; # Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS) NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8" DESTDIR=$DIR/prebuilt/android/armeabi-v7a rm "$DESTDIR"/*.a make clean make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_SYS=Linux TARGET_FLAGS="$NDKF $NDKARCH" if [ -f $SRCDIR/src/libluajit.a ]; then mv $SRCDIR/src/libluajit.a $DESTDIR/libluajit.a fi; # Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS) NDKABI=18 DESTDIR=$DIR/prebuilt/android/x86 NDKVER=$NDK/toolchains/x86-4.9 NDKP=$NDKVER/prebuilt/${host_os}-x86_64/bin/i686-linux-android- NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86" rm "$DESTDIR"/*.a make clean make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_SYS=Linux TARGET_FLAGS="$NDKF" if [ -f $SRCDIR/src/libluajit.a ]; then mv $SRCDIR/src/libluajit.a $DESTDIR/libluajit.a fi; make clean