我正在编译本机源并使用.a libs添加依赖项以及具有以下结构的相关头文件。
/ JNI /
Android.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.c
LOCAL_STATIC_LIBRARY := mschema
include $(BUILD_SHARED_LIBRARY)
native.c
/ JNI / prereqs /
Android.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
- 用于调用子文件夹mk文件
/ JNI / prereqs / mschema /
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE :=mschema
LOCAL_SRC_FILES :=libmschema.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
libmschema.a
/ JNI / prereqs / mschema /包括
标题文件。 (.h)中
但是在尝试使用ndk-build(NDK5)时,我收到了以下错误。
marcos@marcos-AY675AA-AC4-s5320br:~/dev/workspace/rmsdk.native.wraper$ ndk-buildmake:
*** No rule to make target `/home/marcos/dev/workspace/rmsdk.native.wraper/jni/prereqs/mschema/native.c', needed by `/home/marcos/dev/workspace/rmsdk.native.wraper/obj/local/armeabi/objs/ndk1/native.o'. Stop.
键入时我注意到错误是关于/home/marcos/dev/workspace/rmsdk.native.wraper/jni/prereqs/mschema/native.c' and actually this file is under
/ home / marcos / dev / workspace / rmsdk.native.wraper / jni / native.c',我的make文件有什么问题?
将第一个Android.mk更改为以下内容可以避免此问题:
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
LOCAL_PATH :=/home/marcos/dev/workspace/rmsdk.native.wraper/jni
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.c
LOCAL_STATIC_LIBRARY := mschema
include $(BUILD_SHARED_LIBRARY)
但它看起来不对劲。有更好的方法吗?
答案 0 :(得分:35)
从NDK 5中的Docs,解决方案是创建一个局部变量..
我-DIR 返回最后包含的Makefile的路径,通常是 当前的Android.mk目录。这对定义很有用 你的Android.mk开头的LOCAL_PATH和:
LOCAL_PATH := $(call my-dir)
IMPORTANT NOTE: Due to the way GNU Make works, this really returns
the path of the *last* *included* *Makefile* during the parsing of
build scripts. Do not call my-dir after including another file.
所以......为了解决这个问题,我将Android.mk更改为以下内容。
LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_PATH)
LOCAL_LDLIBS := -llog -ldl
LOCAL_MODULE := rmsdk
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)
及其作品。
答案 1 :(得分:0)
我认为在包含子makefile之后def def本地路径是正确的。
LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_PATH)
LOCAL_LDLIBS := -llog -ldl
LOCAL_MODULE := rmsdk
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)
看起来不对劲。我想你可以尝试一下:
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(call my-dir)
LOCAL_LDLIBS := -llog -ldl
LOCAL_MODULE := rmsdk
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)
希望它有所帮助。