14

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?

Community
  • 1
  • 1
CuriousGeorge
  • 7,120
  • 6
  • 42
  • 74

1 Answers1

11

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)
ognian
  • 11,451
  • 4
  • 35
  • 33
  • 1
    thanks. I used the other post to make ndk build the static libs, foudn the static libs and moved them into the local dir, then swapped out the build_static_lib for the part above, and everything is peachy =) – CuriousGeorge May 29 '11 at 15:59
  • After you download the Android NDK, the Android.mk documentation is in docs/ANDROID-MK.html. See http://developer.android.com/sdk/ndk/overview.html#docs – ESV Mar 23 '12 at 16:52
  • @ESV i have did the same but still its not working see http://stackoverflow.com/questions/10106965/how-to-link-any-libarary-in-ndk-application – Jeegar Patel Apr 12 '12 at 06:02
  • there is no lib in my file hierarchy...can you help me with respect to this? – Sreekanth Karumanaghat Jul 24 '12 at 08:58