NDK - 如何使用生成的.so库中的另一个项目 [英] NDK - How to use a generated .so library in another project
问题描述
我已经使用NDK成功地构建和放大器;在一个项目中使用.so文件。我需要使用这个库的另一个项目。我宁愿不复制源存在,而只是使用图书馆。试图复制和;粘贴整个库/ armeabi / libcommon.so到项目的根不工作,我想是因为库/ armeabi是一款Android生成的路径。
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. 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的伽利略和放大器; 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.
-
在code被共享(包括Java JNI封装器,原生code,.so库),应在一个单独的项目。将其转换为一个库项目右键单击项目名称 - >属性 - > Android的属性 - >勾是图书馆。这个项目现在还不能执行,但可以通过其他项目引用。
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.
在其中会使用到共享对象,右键点击项目名称添加引用Libarray项目的项目 - >属性 - > Android的属性 - >库/添加。这应该出现在previous一步创建的库项目。选择它。
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.
现在的。所以可以在不同项目之间被称为容易。
Now the .so can be referred to easily between different projects.
这篇关于NDK - 如何使用生成的.so库中的另一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!