在 NDK 项目中包含预构建的共享对象文件

发布于 2025-01-04 01:14:19 字数 783 浏览 1 评论 0原文

我正在努力通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁许谁一生繁华 2025-01-11 01:14:19

只需将 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文