CMakelists.txt:
add_library (lualib STATIC lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c)
add_executable(lua lua.c)
add_executable(luac luac.c)
target_link_libraries(lua lualib)
target_link_libraries(luac lualib)
编译luac时出现如下错误,是因为liblua链接库没设为静态:
undefined reference to `luaP_opmodes'
...
设成静态库却可解决。或者:
You can try setting LUAI_FUNC
to plain extern
in luaconf.h
(but that will export many private symbols from the shared library), or link luac
with a static liblua.a
as @lhf suggested.(https://stackoverflow.com/questions/33952101/error-while-building-luac-executable-in-rhel6-6)
修改luaconf.h中的680行,原因是 ndk 自带的 Bionic C 库 localeconv 函数返回的 struct lconv 是个空结构(https://blog.csdn.net/fantasyhujian/article/details/8561798)
#if !defined(lua_getlocaledecpoint)
#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
#endif
改成
#if !defined(lua_getlocaledecpoint)
#define lua_getlocaledecpoint() (".")
#endif