5

当我尝试将 .so 编译为 bibiliotek 时,我收到一条错误消息,指出方式不正确,而不是我所期望的本地方式,我看到了 NDK 的方式,这是什么问题,这里是我的 MK 文件:

include $(CLEAR_VARS)

LOCAL_PATH := $(call my-dir)
@echo "Local path = $LOCAL_PATH"

SCRIPT := $(LOCAL_PATH)/LuaJIT/build.sh
ECHO_RESULT1 := $(shell $(SCRIPT))
#ECHO_RESULT := $(shell ($(LOCAL_PATH)/LuaJit/build.sh))
@echo "ECHO_RESULT1=$(ECHO_RESULT1)"

include $(CLEAR_VARS)
LOCAL_MODULE    := libluajit
LOCAL_SRC_FILES := $(LOCAL_PATH)/jnlua/src/libluajit.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := libjnlua
LOCAL_C_INCLUDES += $(LOCAL_PATH)/LuaJit/src
LOCAL_SRC_FILES := $(LOCAL_PATH)/jnlua/src/jnlua.c
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS := -O2 -Wall -DLUA_COMPAT_ALL
#LOCAL_SHARED_LIBRARIES := libjavavm 
LOCAL_STATIC_LIBRARIES := libluajit

# POSIX as we're on linux, and compatibility mode in case you'll be running scripts written for LUA <5.2

include $(BUILD_SHARED_LIBRARY)

在这里我收到一个输出:

11:30:47 **** Incremental Build of configuration Default for project jnlua-android ****
"C:\\Users\\Dev1\\Downloads\\android-ndk-r10e-windows-x86_64\\android-ndk-r10e\\ndk-build.cmd" V=1 all all 
Android NDK: ERROR:jni/Android.mk:luajit: LOCAL_SRC_FILES points to a missing file    
process_begin: CreateProcess(NULL, C:/Users/Dev1/Downloads/android-ndk-r10e-windows-x86_64/android-ndk-r10e/build/core/LuaJIT/build.sh, ...) failed.
C:/Users/Dev1/Downloads/android-ndk-r10e-windows-x86_64/android-ndk-r10e/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting    .  Stop.
Android NDK: Check that C:/Users/Dev1/Downloads/android-ndk-r10e-windows-x86_64/android-ndk-r10e/build/core/jnlua/src/libluajit.a exists  or that its path is correct   

11:30:47 Build Finished (took 122ms)
4

3 回答 3

1
LOCAL_PATH := $(call my-dir)

必须是您的Android.mk文件所做的第一件事。此调用提取最新包含的 makefile 的路径,之后include $(CLEAR_VARS),它将获取$(CLEAR_VARS)文件的路径(ndk/build/core)而不是您的jni目录。

正如@alijandro指出的那样,LOCAL_PATH明确地不在 由.include $(CLEAR_VARS)

于 2018-01-20T09:34:30.873 回答
1

cd 到jni目录并调用ndk-build,这对我有用。

于 2018-01-20T03:17:10.477 回答
0

为了让LOCAL_PATH指向正确的位置,您必须在Android.mk文件顶部分配,之前include $(CLEAR_VARS)CLEAR_VARS不清楚LOCAL_PATH,请参阅文档

CLEAR_VARS 变量指向一个特殊的 GNU Makefile,它为您清除许多 LOCAL_XXX 变量,例如 LOCAL_MODULE、LOCAL_SRC_FILES 和 LOCAL_STATIC_LIBRARIES。请注意,它不会清除 LOCAL_PATH。该变量必须保留其值,因为系统在一个所有变量都是全局的 GNU Make 执行上下文中解析所有构建控制文件。

于 2018-01-20T05:00:31.853 回答