嗨,很抱歉,我正在尝试编译一些静态类,即jsmn.c,json.c和buf.c,它们是我从https://github.com/alisdair/jsmn-example/downloads下载的jsmn json库的一部分.
我正在编译两个STATIC_LIBRARIES lib1和json_librrary.lib1具有依赖于json_library的本机代码,然后将两个库制作成一个共享库,其中包含
?gnustl_static和lib1
我的文件夹结构如下
jni / lib1 / ANdroid.mk
include $(CLEAR_VARS)
LOCAL_MODULE := json_library
LOCAL_SRC_FILES := /3rdParty/jsmn/json_library.a
LOCAL_SRC_FILES := /3rdParty/jsmn/jsmn.c /3rdParty/jsmn/buf.c /3rdParty/jsmn/log.c /3rdParty/jsmn/json.c
LOCAL_C_INCLUDES := /3rdParty/jsmn/jsmn.h /3rdParty/jsmn/buf.h /3rdParty/jsmn/log.h /3rdParty/jsmn/json.h
# Optional compiler flags.
LOCAL_LDLIBS = -lz -lm
LOCAL_CFLAGS = -Wall -pedantic -std=c99 -g
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# Module Name
LOCAL_MODULE := lib1
LOCAL_STATIC_LIBRARIES := json_library
........
.......
......
include $(BUILD_STATIC_LIBRARY)
jni / Android.mk
# Here we give our module name
LOCAL_MODULE := lib2
# list the static modules included here!!!
LOCAL_STATIC_LIBRARIES := gnustl_static lib1
....
include $(BUILD_SHARED_LIBRARY)
jni / Application.mk
APP_MODULES := lib2
# Optimization for release
APP_OPTM := release
#Targets
APP_ABI := armeabi-v7a armeabi
所以在lib1内部,我有一个类,它从名为json_tokenise的json库中调用一个方法.
#include
#include
#include
#include
#include
#include
jsmntok_t *tokens=json_tokenise((char *)data);
typedef enum {
START,
WRAPPER,
MESSAGE,
ROUTE,
OBJECT,
ARRAY,
SKIP,
STOP
}parse_state;
我收到以下错误
undefined reference to `json_tokenise(char*)'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/lib2.so] Error 1
**** Build Finished ****
当我查看[obj / local / armeabi-v7a /
正在为armabi-v7生成libjson_library.a liblib1.a libgnustl_static.a,并且由于错误而无法生成lib2.
请帮助或指导我哪里出了问题我已经花了两天时间,但我还是NDK的新手.