gpt4 book ai didi

java - 没有制定目标 NDK 的规则

转载 作者:IT王子 更新时间:2023-10-28 23:35:55 24 4
gpt4 key购买 nike

我正在编译原生源代码并使用 .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/include

Header files. (.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' 而实际上这个文件在/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 的文档中,解决方案是创建一个局部变量..

我的目录 返回最后包含的 Makefile 的路径,通常是 当前 Android.mk 的目录。这有助于定义 LOCAL_PATH 在您的 Android.mk 开头,如下所示:

    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)

及其作品。

关于java - 没有制定目标 NDK 的规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4585591/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com