问题描述
喜对不起,长的帖子我试图编译一些静态类即jsmn.c,json.c和buf.c哪些是jsmn JSON库从我的。
Hi Sorry for the long post I am trying to compile some static classes namely jsmn.c,json.c and buf.c which are part of the jsmn json library I downloaded from https://github.com/alisdair/jsmn-example/downloads.
我编译2 STATIC_LIBRARIES LIB1和json_librrary.lib1具有本地code这是依赖于json_library.Then我想提出两个库到包含共享库
gnustl_static和LIB1
I am compiling two STATIC_LIBRARIES lib1 and json_librrary.lib1 has native code which is dependent on json_library.Then I am making two libraries into a shared library containing gnustl_static AND 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库 json_tokenise
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <jsmn/jsmn.h>
#include <jsmn/json.h>
#include <jsmn/buf.h>
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 /本地/ armeabi-V7A /我可以看到
libjson_library.a liblib1.a libgnustl_static.a 是如何产生的armabi-V7,也未能产生,因为错误的LIB2。
When I have a look inside [obj/local/armeabi-v7a/ I can seelibjson_library.a liblib1.a libgnustl_static.a are getting generated for the armabi-v7 and it fails to generate lib2 because of the error.
请帮助或引导我在哪里,我错了我在这花了两天时间,我是新来的NDK。
Please help or guide me where I am going wrong I have spent two days on this and I am new to NDK.
推荐答案
您应该修正 JNI / LIB1 / Android.mk
文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := json_library
LOCAL_SRC_FILES := 3rdParty/jsmn/jsmn.c 3rdParty/jsmn/buf.c 3rdParty/jsmn/log.c 3rdParty/jsmn/json.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/3rdParty/jsmn
# Optional compiler flags.
LOCAL_LDLIBS = -lz -lm
LOCAL_CFLAGS = -Wall -pedantic -std=c99 -g
include $(BUILD_STATIC_LIBRARY)
如果您之后仍存在问题,请运行 NDK的构建
带参数在命令行V = 1
并张贴这个版本和所有 Android.mk
文件的全部内容的完整输出。
If you still have problems after this, please run ndk-build
with parameter V=1
on command line and post the full output of this build and full content of all your Android.mk
files.
这篇关于Android的NDK未定义的引用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!