1

I want my native executable to be auto-populated to /data/data/.../lib/. For this it is to be named like lib*.so. But if I try to set this name, Android NDK complains:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := libhello.so
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)
Android NDK: jni/Android.mk:hello.so: LOCAL_MODULE_FILENAME must not contain a file extension
4

2 回答 2

2

A workaround: install with a name Android NDK wants, then rename after installation:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := hello
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)

all:
        mv ${NDK_APP_DST_DIR}/hello ${NDK_APP_DST_DIR}/libhello.so

And your application can call the executable /data/data/<package>/lib/libhello.so without any preparatory steps.

于 2014-07-14T16:11:56.897 回答
-1

You are trying to build an executable instead of a shared library. You want to change this:

include $(BUILD_EXECUTABLE)

to this:

include $(BUILD_SHARED_LIBRARY)
于 2016-09-28T14:38:49.193 回答