Android.mk try access .so file - android

I want to include *.so in Android.mk. Here is my code save in app/jni/Android.mk
The .so file is same in app/jni/libdpfr6.so
My code is
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libdpfr6
LOCAL_SRC_FILES := libdpfr6.so
include $(PREBUILT_STATIC_LIBRARY)
but after running the app I got a error.
LOCAL_SRC_FILES should point to a file ending with ".a"
Android NDK: The following file is unsupported: libdpfr6.so
I need help.

Related

LOCAL_SRC_FILES should point to a file ending with ".so"

when use ndk-r10e to build my project with static library, in the Android.mk, through,
include $(CLEAR_VARS)
LOCAL_MODULE := game-cocos2dx
LOCAL_SRC_FILES := ../../../AgoraGamingSDK/libs/android/$(TARGET_ARCH_ABI)/libgame-cocos2dx.a
include $(PREBUILT_STATIC_LIBRARY)
But get the error log:
LOCAL_SRC_FILES should point to a file ending with ".so"
Updating ndk to android-ndk-r14b,can make it.

How to use ndk-build build the source files in different folders?

I know that to build so file, I should put the source file in /jni/ folder.
But how can I build separate so in different folders.
For example, the structure of my project:
/jni/Android.mk
/jni/submodule1/Android.mk
/jni/submodule1/sub1.c
/jni/submodule2/Android.mk
/jni/submodule2/sub2.c
I have tried to write this in Android.mk in the top level:
$(LOCAL_PATH) :=$(call all-makefiles-under)
then wrote make info in Android.mk in submodule
the error is:
ndk-build
make: *** No rule to make target `/home/../workspace/jni/sub.c', needed b
y `/home/../workspace/obj/local/armeabi/objs/submodule/sub.o'. Stop.
Can someone give me a solution? Thank you!
Update 1:
The code of Android.mk in submoudle:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := sub.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_MODULE := sub
LOCAL_LDLIBS := -ldl -llog
LOCAL_STATIC_LIBRARIES := libc
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := debug
include $(BUILD_EXECUTABLE)
SOLVED:
I should use ndk-build in the root directory, but not in jni directory. Thanks all of you!
You should try include $(call all-subdir-makefiles) rather then $(LOCAL_PATH) :=$(call all-makefiles-under) in main Android.mk and make folder under jni folder with there separate c files and Android.mk files
Have you tried something like:
LOCAL_PATH := $(call my-dir)
LOCAL_SRC_FILES := /submodule1/sub1.c

Linking dependent .so files with ndk-build for Android

I have created a .so file that exposes a native C call to Java via JNI. This works well and I can deploy the app onto my Android system if I just use system libraries in my C code. However, if I want to make calls to functions in other .so files, I cannot get my project to link correctly.
For example, say I have the "libotherso.so" file which contains APIs defined in C that I can call from the "MyJNILibrary.c" code I'm using to generate "libMyJNILibrary.so".
I tried to change my Android.mk file as follows:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyJNILibrary
LOCAL_SRC_FILES := MyJNILibrary.c
LOCAL_LDLIBS += -lotherso
include $(BUILD_SHARED_LIBRARY)
But when I call ndk-build on this, I get errors finding -lotherso. Where do I put the "libotherso.so" file so that ndk-build can pick it up?
Thanks for any help you can provide.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := otherso
LOCAL_SRC_FILES := ../lib/libotherso.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := MyJNILibrary
LOCAL_SRC_FILES := MyJNILibrary.c
LOCAL_SHARED_LIBRARIES := otherso
include $(BUILD_SHARED_LIBRARY)
Note that LOCAL_SRC_FILES is relative to your LOCAL_PATH.
Don't forget to load your dependency before your own JNI library:
static {
System.loadLibrary("otherso");
System.loadLibrary("MyJNILibrary");
}

How to import one android.mk mdule into another android.mk module in Android?

In Android in the Application i want to import one android.mk file into another Android.mk file in the Application
for this i have used in one Andorid.mk file which is to be imported into another module of same project
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := EDSDKModule
LOCAL_SRC_FILES :=libEDSDK.a
LOCAL_ARM_MODE := arm
TARGET_PLATFORM:=android-8
TARGET_ARCH_ABI:=armeabi
TARGET_ABI:=$(TARGET_PLATFORM)-$(TARGET_ARCH_ABI)
include $(PREBUILT_STATIC_LIBRARY)
and main Andorid.mk file is written is
include C:\my_module\Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := EDSK
LOCAL_MODULE_FILENAME := foo
LOCAL_SRC_FILES := sample.c
LOCAL_STATIC_LIBRARIES := EDSDKModule
include $(BUILD_SHARED_LIBRARY)
LOCAL_ARM_MODE := arm
TARGET_PLATFORM:=android-8
TARGET_ARCH_ABI:=armeabi
TARGET_ABI:=$(TARGET_PLATFORM)-$(TARGET_ARCH_ABI)
$(call import-module,EDSDKModule)
but i have got this error on building project using Android-NDk i.e
please suggest some solutions on how to import one module into another module of android.mk file in a project
I am guessing the problem is here :
$NDK_MODULE_PATH\C:\Final FOlder\final c\Mysetup\newworks\SimpleApp\jni\path1\Android.mk:
/*here i have given directory path of android.mk file */
Possible mistakes :
Try to get rid of the empty spaces in the path :
C:\Final FOlder\final c\
to something like this :
C:\FInal_Folder\final_c\myotherdir\xyz.mk
If you are using a absolute path like :
C:\mypath\myotherdir\xyz.mk
then you NEED NOT prefix it with $NDK_MODULE_PATH. Just use the above absolute path itself, which is C:\mypath\myotherdir\xyz.mk
You need an include keyword infront of your above include statement :
# comment : including my mk file here
include C:\mypath\myotherdir\xyz.mk
Get rid of the : in the end of your include statement
So you have to do something like :
include C:\mypath\myotherdir\xyz.mk
OR
If you have the mk file in NDK LOCAL FOLDER then
include $NDK_MODULE_PATH\mylocaldir\xyz.mk
Hope this helps. CHeers!

Building cross platform sources with android.mk in NDK

I need to build some cross platform cpp files in my android mk file. These sources are not in sub directories of the jni directory.
Currently i have something like below, is there some way to avoid the long relative paths to describe where the source files are located? What is best practice here?
Thanks
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := host
LOCAL_SRC_FILES := ../../../../../Dev/common/host.c
include $(BUILD_STATIC_LIBRARY)
You can define your own variables in mk file:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
SRC_ROOT := ../../../../../Dev
LOCAL_MODULE := host
LOCAL_SRC_FILES := $(SRC_ROOT)/common/host.c
include $(BUILD_STATIC_LIBRARY)

Categories

Resources