jsoncpp 的 ndk-build 总是给出一个错误
ndk-build for jsoncpp always giving one error
先决条件:我正在使用 Android Studio 2.1.2
我已经从以下 link
下载了 jsoncpp 的源代码
https://github.com/open-source-parsers/jsoncpp
我已经检查了以下 SO 线程,没有得到正确的解决方案:
LOCAL_MODULE_FILENAME should not include file extensions i get this error each time i run ndk-build in terminal
Using JsonCpp on X-Cross platform library
我的常用Android.mk如下:
LOCAL_PATH := $(call my-dir)
#JsonCpp lib
include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
include $(LOCAL_PATH)/jsnlib/Android.mk
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
还有用于构建其他一些库的代码,工作正常。
我的jsoncpp的Android.mk如下
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/jsnlib/include/json/*.h
FILE_LIST += $(wildcard $(LOCAL_PATH)/jsnlib/src/lib_json/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_MODULE := jsnlib
LOCAL_MODULE_FILENAME:= libjsnlib
include $(BUILD_STATIC_LIBRARY)
当我执行 ndk-build 时总是出现以下错误
Android NDK: jni/jsnlib/Android.mk:jsnlib: LOCAL_MODULE_FILENAME should not include file extensions
Android NDK: jni/jsnlib/Android.mk:jsnlib: LOCAL_MODULE_FILENAME must not contain a file extension
这里发生的是,当您在定义 jsoncpplib
模块时,您包含了另一个 makefile,它包含自己的模块定义:
include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
include $(LOCAL_PATH)/jsnlib/Android.mk
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
您应该将另一个 makefile 的包含移动到您正在执行的位置之上 CLEAR_VARS
:
include $(LOCAL_PATH)/jsnlib/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
此外,LOCAL_MODULE_FILENAME:= libjsnlib
似乎是多余的,因为 LOCAL_MODULE := jsnlib
应该产生相同的库名称。
先决条件:我正在使用 Android Studio 2.1.2
我已经从以下 link
下载了 jsoncpp 的源代码https://github.com/open-source-parsers/jsoncpp
我已经检查了以下 SO 线程,没有得到正确的解决方案:
LOCAL_MODULE_FILENAME should not include file extensions i get this error each time i run ndk-build in terminal
Using JsonCpp on X-Cross platform library
我的常用Android.mk如下:
LOCAL_PATH := $(call my-dir)
#JsonCpp lib
include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
include $(LOCAL_PATH)/jsnlib/Android.mk
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
还有用于构建其他一些库的代码,工作正常。
我的jsoncpp的Android.mk如下
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/jsnlib/include/json/*.h
FILE_LIST += $(wildcard $(LOCAL_PATH)/jsnlib/src/lib_json/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_MODULE := jsnlib
LOCAL_MODULE_FILENAME:= libjsnlib
include $(BUILD_STATIC_LIBRARY)
当我执行 ndk-build 时总是出现以下错误
Android NDK: jni/jsnlib/Android.mk:jsnlib: LOCAL_MODULE_FILENAME should not include file extensions
Android NDK: jni/jsnlib/Android.mk:jsnlib: LOCAL_MODULE_FILENAME must not contain a file extension
这里发生的是,当您在定义 jsoncpplib
模块时,您包含了另一个 makefile,它包含自己的模块定义:
include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
include $(LOCAL_PATH)/jsnlib/Android.mk
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
您应该将另一个 makefile 的包含移动到您正在执行的位置之上 CLEAR_VARS
:
include $(LOCAL_PATH)/jsnlib/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := jsoncpplib
LOCAL_STATIC_LIBRARIES := jsnlib
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
此外,LOCAL_MODULE_FILENAME:= libjsnlib
似乎是多余的,因为 LOCAL_MODULE := jsnlib
应该产生相同的库名称。