I wanted to make a game which was built in C++ and uses Lua for scripting purposes. For that, I made my own Lua Engine. For Windows, I simply included the Lua Header Files, the Lua library and the Lua dll. This works perfectly fine.
Now I want to import the same project for Android. The problem I am facing is that when building, it gives ‘undefined reference’ to all the Lua calls that I make. It is able to include the Lua header files, but it’s still not compiling.
EDIT 1: Now I assume that’s because of not linking the lib and .dll file. I know that Android doesn't use dll and lib files as Windows. It uses .so files. But can anyone suggest me how to build .so files!?
EDIT 2: So I did more research and finally build the .so files. But now I have four set of libraries: ar64-v8a, armeabi-v7a, x86, x86-64. Can anyone tell me what is the difference between these set of libraries, and how to actually use them into my main cocos project!?
#lua
LIB_VERSION:=lua-5.2.2
LOCAL_PATH:= $(call my-dir)
LIB_ROOT_REL:= ../../$(LIB_VERSION)
LIB_ROOT_ABS:= $(LOCAL_PATH)/../../$(LIB_VERSION)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -O2 -Wall -DLUA_COMPAT_ALL -D"getlocaledecpoint() ='.'"
LOCAL_SRC_FILES := \
<ALL LUA SOURCE FILES INCLUDED HERE>
LOCAL_C_INCLUDES += \
$(LIB_ROOT_ABS)/src \
LOCAL_LDLIBS += -llog
LOCAL_MODULE := liblua
include $(BUILD_SHARED_LIBRARY)
The four different files you have are for the four different architectures - ar64-v8a, armeabi-v7a, x86, x86-64. Depending on which architectures you plan to support, you will have to add the corresponding folder under libs and copy the appropriate .so file inside that folder. So if you plan to support only armeabi-v7a, then you have to create a folder called armeabi-v7a inside the libs folder and add the armeabi-v7a so file to it.