How to compile Lua for Android

Update lmathlib.c

  1. Index: lmathlib.c
  2. ===================================================================
  3. --- lmathlib.c	(revision 4050)
  4. +++ lmathlib.c	(revision 4051)
  5. @@ -183,10 +183,10 @@
  6.      res = l_mathop(log)(x);
  7.    else {
  8.      lua_Number base = luaL_checknumber(L, 2);
  9. -#if !defined(LUA_USE_C89)
  10. -    if (base == l_mathop(2.0))
  11. -      res = l_mathop(log2)(x); else
  12. -#endif
  13. +//#if !defined(LUA_USE_C89)
  14. +//    if (base == l_mathop(2.0))
  15. +//      res = l_mathop(log2)(x); else
  16. +//#endif
  17.      if (base == l_mathop(10.0))
  18.        res = l_mathop(log10)(x);
  19.      else

Update luaconf.h

  1. Index: luaconf.h
  2. ===================================================================
  3. --- luaconf.h	(revision 4050)
  4. +++ luaconf.h	(revision 4051)
  5. @@ -677,7 +677,7 @@
  6.  ** macro must include header 'locale.h'.)
  7.  */
  8.  #if !defined(lua_getlocaledecpoint)
  9. -#define lua_getlocaledecpoint()		(localeconv()->decimal_point[0])
  10. +#define lua_getlocaledecpoint()		('.')
  11.  #endif
  12.  
  13.  /* }================================================================== */

Android.mk

  1. #
  2. # Android.mk
  3. #
  4. # Lua
  5. #
  6. LOCAL_PATH := $(call my-dir)/../src
  7.  
  8. include $(CLEAR_VARS)
  9.  
  10. LOCAL_MODULE     := Lua
  11. LOCAL_CPPFLAGS   := -std=c++17
  12. LOCAL_SRC_FILES := \
  13.     $(LOCAL_PATH)/lapi.c \
  14.     $(LOCAL_PATH)/lauxlib.c \
  15.     $(LOCAL_PATH)/lbaselib.c \
  16.     $(LOCAL_PATH)/lbitlib.c \
  17.     $(LOCAL_PATH)/lcode.c \
  18.     $(LOCAL_PATH)/lcorolib.c \
  19.     $(LOCAL_PATH)/lctype.c \
  20.     $(LOCAL_PATH)/ldblib.c \
  21.     $(LOCAL_PATH)/ldebug.c \
  22.     $(LOCAL_PATH)/ldo.c \
  23.     $(LOCAL_PATH)/ldump.c \
  24.     $(LOCAL_PATH)/lfunc.c \
  25.     $(LOCAL_PATH)/lgc.c \
  26.     $(LOCAL_PATH)/linit.c \
  27.     $(LOCAL_PATH)/liolib.c \
  28.     $(LOCAL_PATH)/llex.c \
  29.     $(LOCAL_PATH)/lmathlib.c \
  30.     $(LOCAL_PATH)/lmem.c \
  31.     $(LOCAL_PATH)/loadlib.c \
  32.     $(LOCAL_PATH)/lobject.c \
  33.     $(LOCAL_PATH)/lopcodes.c \
  34.     $(LOCAL_PATH)/loslib.c \
  35.     $(LOCAL_PATH)/lparser.c \
  36.     $(LOCAL_PATH)/lstate.c \
  37.     $(LOCAL_PATH)/lstring.c \
  38.     $(LOCAL_PATH)/lstrlib.c \
  39.     $(LOCAL_PATH)/ltable.c \
  40.     $(LOCAL_PATH)/ltablib.c \
  41.     $(LOCAL_PATH)/ltm.c \
  42.     $(LOCAL_PATH)/lua.c \
  43.     $(LOCAL_PATH)/luac.c \
  44.     $(LOCAL_PATH)/lundump.c \
  45.     $(LOCAL_PATH)/lutf8lib.c \
  46.     $(LOCAL_PATH)/lvm.c \
  47.     $(LOCAL_PATH)/lzio.c
  48.  
  49. include $(BUILD_STATIC_LIBRARY)

Leave a Reply

Your email address will not be published. Required fields are marked *