为什么在Android.mk文件中$(调用my-dir)返回错误的路径?

时间:2016-02-17 08:41:54

标签: android makefile android-ndk ndk-build

当我尝试编译.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)

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

为了让(.git/hooks/pre-commit)指向正确的位置,您必须在pre-commit文件的顶部指定LOCAL_PATHAndroid.mk不要清除include $(CLEAR_VARS),请参阅documentation

  

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

答案 2 :(得分:0)

LOCAL_PATH := $(call my-dir)

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

正如@alijandro指出的那样, LOCAL _ 的长列表中明确缺少 LOCAL_PATH 。{/ 1}}重置了 LOCAL _