Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NDK - How to use a generated .so library in another project

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?

I am using Eclipse-Galileo & ndk5.

like image 992
OceanBlue Avatar asked Apr 14 '11 20:04

OceanBlue


1 Answers

There is a much simpler way to do all of this.

Let's say that your prebuilt library is called "libprebuilt.so"

In the project folder of the new project you want to only include the prebuilt library, do something like:

mkdir -p jni/libprebuilt cp libprebuilt.so jni/libprebuilt 

Then, just create a jni/libprebuilt/Android.mk file:

LOCAL_PATH := $(call my-dir)  include $(CLEAR_VARS) LOCAL_MODULE := libprebuilt LOCAL_SRC_FILES := libprebuilt.so include $(PREBUILT_SHARED_LIBRARY) 

Then when you do ndk-build, it will copy this library in to libs/armeabi/ ... that's all!

like image 98
gnychis Avatar answered Sep 30 '22 20:09

gnychis