Build android shared lib using ndk-build without have jni folder

 ̄綄美尐妖づ 提交于 2020-01-01 06:27:11

问题


I am able to build a android shared library using ndk-build only when all my src are in the jni foler, but, I would like to build a shared library using ndk-build without need jni folder, because my project doesn't have java code, so how could I do that?

my simple Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := ctest
LOCAL_SRC_FILES := main.cpp
# for logging
LOCAL_LDLIBS    += -llog
# for native asset manager
LOCAL_LDLIBS    += -landroid

include $(BUILD_SHARED_LIBRARY)

回答1:


worked as follows:

ndk-build APP_BUILD_SCRIPT=path/to/path/to/project/Android.mk NDK_PROJECT_PATH=path/to/path/to/project



回答2:


I would still recommend using a subdirectory like jni for storing the source, to keep the build products in subdirectories such as obj, libs and bin more clearly separated.

But if you have your Android.mk elsewhere, you should be able to do ndk-build APP_BUILD_SCRIPT=path/to/Android.mk. If you don't want to type this every time, you can add a file named jni/Application.mk where you type APP_BUILD_SCRIPT=path/to/Android.mk. Alternatively you have a file named jni/Android.mk which then includes the real Android.mk from where you store it.



来源:https://stackoverflow.com/questions/25868989/build-android-shared-lib-using-ndk-build-without-have-jni-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!