在Android NDK项目中使用我自己的prebuilt共享库自己的、项目、Android、NDK

由网友(再无交集)分享简介:我碰到这个职位几乎是我所需要的:How使用Android NDK编译静态库? 基本上,有某些部分在我的项目,从来没有更新,所以我尽量避免让他们建每一次我更新Android.mk文件中添加一些东西。以上回答显示了如何获得一些内置到一个单独的静态库的code,但是当我尝试$ P $在一个单独的Andr​​oid.mk文件,...

我碰到这个职位几乎是我所需要的:

How使用Android NDK编译静态库?

  

基本上,有某些部分在我的项目,从来没有更新,所以我尽量避免让他们建每一次我更新Android.mk文件中添加一些东西。

以上回答显示了如何获得一些内置到一个单独的静态库的code,但是当我尝试$ P $在一个单独的Andr​​oid.mk文件,对建立上述code,它不会自动建立。这似乎有点多余的......如果我有在同一时间来建立他们两个,那有什么使点一个单独的静态库反正?

如果我在单独的项目改变Android.mk阅读:

  

包括$(BUILD_SHARED_LIBRARY)

和包括像这样的主要项目:

  

LOCAL_SHARED_LIBRARIES:= libMyaccessories.so

然后我得到无法解析的引用(函数名),可能是因为它无法找到共享库(这是在调用路径)

  

谁能帮我这个?

解决方案

在Android.mk的文件,检查 preBUILT_SHARED_LIBRARY 脚本描述。放入的.so文件LIB (而不是)目录编写下一一个Android.mk文件,它看起来是这样的:

  LOCAL_PATH:= $(叫我-DIR)

包括$(CLEAR_VARS)

LOCAL_MODULE:= Myaccessories
LOCAL_SRC_FILES:= libMyaccessories.so
LOCAL_C_INCLUDES:= $(LOCAL_PATH)/../ JNI /包括

包括$(preBUILT_SHARED_LIBRARY)
 
Android 7 Android NDK开发 第一个Jni实践

I came across this post that is almost what I need:

How to compile a static library using the Android NDK?

Basically, there are certain parts in my project that are never updated, so I am trying to avoid having them built every single time I update the Android.mk file to add something.

The above answer shows how to get some of the code built into a separate static lib, but when I try to pre-build the above code in a separate Android.mk file, It won't build by itself. This seems a little redundant... If I have to build them both at the same time, then what's the point of making a separate static lib anyways?

And if I change Android.mk in the separate project to read:

include $(BUILD_SHARED_LIBRARY)

and include it like this in the main project:

LOCAL_SHARED_LIBRARIES := libMyaccessories.so

then I get unresolved reference to(function name), probably because it can't find the shared lib(which is in the calling path)

Can anyone help me out with this?

解决方案

In the documentation of Android.mk, check the PREBUILT_SHARED_LIBRARY script description. Put the .so file in lib (not libs) directory and write an Android.mk file next to it that looks something like:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := Myaccessories
LOCAL_SRC_FILES := libMyaccessories.so
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../jni/include

include $(PREBUILT_SHARED_LIBRARY)

阅读全文

相关推荐

最新文章