在 NDK 项目中包含预构建的共享对象文件
我正在努力通过 NDK 项目将共享对象文件包含到 Android 操作系统映像中。
android.mk 文件如下所示
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Myaccessories
LOCAL_SRC_FILES := libMyaccessories.so
include $(PREBUILT_SHARED_LIBRARY)
我已将“libMyaccessories.so”添加到 android.mk 所在的 jni 文件夹中。在 ndk-built 上,它会导致错误,如下所示
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
我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将 .so 文件放入 libs/armeabi/ 子目录中,它就会自动包含在构建中。不要在 LOCAL_SRC_FILES 中提及它,因为它不是源文件。
如果该库是从本机代码引用的,而不仅仅是 Java 代码,那么您可能需要将其列在 LOCAL_LDLIBS 中,但如果这不是默认值,我会感到非常惊讶。
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.