Vi. Vi. - 2 months ago 8
Android Question

How do I make ndk-build create executable named like a library?

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

Vi. Vi.
Answer

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.