NDK - 如何在另一个项目中使用生成的 .so 库 [英] NDK - How to use a generated .so library in another project

查看:21
本文介绍了NDK - 如何在另一个项目中使用生成的 .so 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功使用ndk构建&在一个项目中使用 .so 文件.我需要在另一个项目中使用这个库.我宁愿不在那里复制源代码,而只是使用库.

I have used ndk successfully to build & use a .so file in one project. I need to use this library in another project. I would rather not copy the source there, but just use the library.

试图复制 &将整个 libs/armeabi/libcommon.so 粘贴到项目根目录不起作用,我认为是因为 libs/armeabi 是android生成的路径.

Trying to copy & paste the whole libs/armeabi/libcommon.so to the project root does not work, I think because libs/armeabi is an android generated path.

那么最好的方法是什么?

So what would be the best way to do it?

我正在使用 Eclipse-Galileo &ndk5.

I am using Eclipse-Galileo & ndk5.

推荐答案

我想出了一个办法,所以把它贴在这里以防其他人遇到它.

I figured out a way to do this, so posting it here in case someone else runs into it.

  1. 要共享的代码(包括 Java JNI 包装器、本机代码、.so 库)应位于单独的项目中.通过右键单击项目名称-> 属性-> Android 属性-> 选中是库"将其转换为库项目.该项目现在无法执行,但可以被其他项目引用.

  1. The code to be shared (including the Java JNI wrapper, native code, .so library), should be in a separate project. Convert this to a Library project by right-click on project name --> properties --> Android properties --> check mark "Is Library". This project cannot be executed now but can be referenced by other projects.

在将使用共享对象的项目中,通过右键单击项目名称 --> 属性 --> Android 属性 --> 库/添加"来添加对 Libarray 项目的引用.这应该会显示在上一步中创建的库项目.选择它.

In the project which will use the shared object, add a reference to the Libarray project by right-click on project name --> properties --> Android properties --> Library/"Add". This should show up the Library project created in the previous step. Select it.

现在.so 可以在不同项目之间轻松引用.

Now the .so can be referred to easily between different projects.

这篇关于NDK - 如何在另一个项目中使用生成的 .so 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆