没有规则做目标NDK

我正在编译本机资源,并添加依赖与.a库和相关的头文件与下面的结构。

/ 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. 

input时我注意到错误是关于/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) 

但是看起来错了。 有更好的方法吗?

从NDK 5中的文档,解决scheme是创build一个局部variables..

my-dir返回最后包含的Makefile的path,通常是当前的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) 

和它的作品。

包含子makefiles后,我认为确定本地path是正确的。

 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) 

希望能帮助到你。