java 没有制定目标 NDK 的规则
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4585591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No rule to make target NDK
提问by Marcos Vasconcelos
I'm compiling native sources and adding the dependencies with .a libs and those relative header files with the following structure.
我正在编译本机源并使用 .a 库和具有以下结构的相关头文件添加依赖项。
/jni/
/jni/
Android.mk
安卓.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/
/jni/先决条件/
Android.mk
安卓.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
--Used to call the sub-folders mk files
--用于调用子文件夹mk文件
/jni/prereqs/mschema/
/jni/prereqs/mschema/
Android.mk
安卓.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/include
/jni/prereqs/mschema/include
Header files. (.h)
头文件。(。H)
But while trying to ndk-build (NDK5) I got the following error.
但是在尝试 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.
While typing I noted the error is about /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', what's wrong in my make files?
在输入时,我注意到错误是关于/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 文件有什么问题?
The problem could be avoided by changing the first Android.mk to the following:
可以通过将第一个 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)
But it looks wrong. Is there a better approach?
但看起来不对。有没有更好的方法?
回答by Marcos Vasconcelos
From the Docs in NDK 5, the solution is to create a local variable..
从 NDK 5 中的文档,解决方案是创建一个局部变量..
my-dir Returns the path of the last included Makefile, which typically is the current Android.mk's directory. This is useful to define LOCAL_PATH at the start of your Android.mk as with:
my-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.
So.. to solve this problem I change my Android.mk to the following.
所以..为了解决这个问题,我将我的 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)
And its works.
以及它的作品。
回答by busylee
I think it is true to def local path after including sub makefiles.
我认为在包含子 makefile 之后定义本地路径是正确的。
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)
It looks wrong. I think you can just try this:
看起来不对。我想你可以试试这个:
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)
Hope it helps.
希望能帮助到你。