android – 重用arm共享库

android – 重用arm共享库,第1张

概述我已经建立了arm arm共享库(libtest.so).我有兴趣重用一个函数(没有很多依赖项 – 它只创建类实例并调用两个方法).我想调用该函数(它需要一个std :: string参数)并获得返回值. 有可能做这样的事吗?我没有任何头文件. 我试过这个Android.mk,我把libtest.so放在/ jni和/ libs / armeabi,/ lib / armeabi中.此时我的cpp 我已经建立了arm arm共享库(libtest.so).我有兴趣重用一个函数(没有很多依赖项 – 它只创建类实例并调用两个方法).我想调用该函数(它需要一个std :: string参数)并获得返回值.

有可能做这样的事吗?我没有任何头文件.

我试过这个Android.mk,我把libtest.so放在/ jni和/ libs / armeabi,/ lib / armeabi中.此时我的cpp文件编译,但现在是什么?如果可能,我如何从libtest.so调用函数?我从objdump知道它的名字

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODulE:= libtest LOCAL_SRC_fileS := libtest.so include $(PREBUILT_SHARED_liBRARY) include $(CLEAR_VARS) LOCAL_MODulE    := hello-jni LOCAL_SRC_fileS := hello-jni.cpp LOCAL_SHARED_liBRARIES := libtest include $(BUILD_SHARED_liBRARY)

编辑:

我试图用这个androID.mk从hello-jni示例中添加prebuild库:

include $(CLEAR_VARS)LOCAL_MODulE:= libhello-jniLOCAL_SRC_fileS := libhello-jni.soinclude $(PREBUILT_SHARED_liBRARY)

它工作,但libtest.so相同的代码显示以下错误(启动时)

UnsatisfIEdlinkError: Cannot load libtest.so: Findlibrary returned null

libtest.so存在于libhello-jni.so旁边的文件夹中(在/ data / data / [package] / lib上的设备上).可能有什么不对?

解决方法 我有一个应用程序,我做了类似于你需要的东西(或者你可能正是你需要的东西).

>我有* .so文件形式的预编译库. (例如lib1.so,lib2.so等),
它带有一些标题.
>我创建了一个模块,它通过包含头文件和* .so文件来利用预编译库.在示例中,我将其称为“libtestwrapper”.该模块定义了自己的源文件,并可选择包含.如下所述,可以为第二个模块导出模块功能(如果提供头文件).
>我创建了第二个模块(newModule),它将第一个模块(libtestwrapper)添加到’LOCAL_SHARED_liBRARIES’中.这使得先前导出的头文件(在’libtestwrapper’中)可用于’newModule’.

这是我的AndroID.mk的内容:

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODulE := libtestwrapperLOCAL_SRC_fileS := libtestUsage.c # Use the methods of libtest.h hereLOCAL_C_INCLUDES := $(LOCAL_PATH)/include # This is where libtest.h should be# provIDe this line if you intend to export any header files to another module#LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/include # you may also use a different directory than 'include'LOCAL_LDliBS := -L$(LOCAL_PATH)/dir_with_libtest_so -libtest # -llog etc.                                #optionally add any as needed: -llog -ljnigraphics -lz -ldl -lgcc                                # '-libtest' corresponds to 'libtest.so' - the names must match                                # -llog is for logcat for exampleinclude $(BUILD_SHARED_liBRARY)# Optional:# define a second module wich is making use of the first one (i.e. libtestwrapper)include $(CLEAR_VARS)LOCAL_MODulE := newModule # this module will be making use of the first one (if needed)                    # Add local source files. If the files are stored in directorIEs                    # you have to provIDe a relative path  starting insIDe the 'jni' directory.                    # The example is for this structure: jni/dirToSourcefiles1/*.cppLOCAL_SRC_fileS := dirToSourcefiles1/Sourcefile1.cpp dirToSourcefiles1/Sourcefile2.cppLOCAL_C_INCLUDES += $(LOCAL_PATH)/newModule_include # path where the headers of this module are storedLOCAL_SHARED_liBRARIES += libtestwrapper # make use of the prevIoUs module# Optionally add this line if any other libs should be used#LOCAL_LDliBS := -llog -ljnigraphics -lz -ldl -lgccinclude $(BUILD_SHARED_liBRARY)
总结

以上是内存溢出为你收集整理的android – 重用arm共享库全部内容,希望文章能够帮你解决android – 重用arm共享库所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1139203.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存