Including a prebuilt shared object file in an NDK project

邮差的信 提交于 2019-12-11 01:55:01

问题


I am working on including a shared object file onto the Android OS image through the NDK project.

The android.mk file looks like this

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := Myaccessories
LOCAL_SRC_FILES := libMyaccessories.so

include $(PREBUILT_SHARED_LIBRARY)

And I have added the "libMyaccessories.so" to the jni folder where the android.mk is located. On ndk-built, it results in error which is as below

Prebuilt       : libMyaccessories.so <= jni/
Install        : libMyaccessories.so => libs/armeabi/libMyaccessories.so
/home/Identive/Desktop/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip: Unable to recognise the format of the input file `./libs/armeabi/libMyaccessories.so'
make: *** [libs/armeabi/libMyaccessories.so] Error 1

How can I resolve this?


回答1:


Just put the .so file in your libs/armeabi/ subdirectory, and it should automatically be included as part of your build. Don’t mention it in LOCAL_SRC_FILES, as it’s not a source file.

If that library is being referenced from native code, not just Java code, you may need to list it in LOCAL_LDLIBS, but I’d be very surprised if this isn’t the default.



来源:https://stackoverflow.com/questions/9205245/including-a-prebuilt-shared-object-file-in-an-ndk-project

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