How to use existing static library (.a file) to create shared library (.so file)

5,176 views
Skip to first unread message

Reddy

unread,
Aug 6, 2010, 5:40:57 AM8/6/10
to android-ndk
Hi,

I have an already existing Static library created in android version
1.6. Now i want to use this static library in creation of Shared
library. Please tell me where i need to keep the Static library so
that the Android.mk file can access this.

/Reddy

Onur Cinar

unread,
Aug 6, 2010, 7:17:45 PM8/6/10
to andro...@googlegroups.com

Hi Reddy,

It would be better to keep the .a file in your project directory, since it will get deleted if you manually put it into the NDK's work directories.

If you add the following into your Android.mk file it should be fine I think.

LOCAL_LDLIBS += $(LOCAL_PATH)/../library.a

That's how I'm linking closed-code 3rd party Android libraries into the project.

Regards,

-onur



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Dennis Muhlestein

unread,
Aug 6, 2010, 11:13:51 AM8/6/10
to andro...@googlegroups.com


Here is my layout:

jni/static/Android.mk
-> ....
-> LOCAL_MODULE := mystaticlib
-> include $(BUILD_STATIC_LIBRARY)
jni/shared/Android.mk
-> LOCAL_STATIC_LIBRARIES := mystaticlib
-> include $(BUILD_SHARED_LIBRARY)

Senior rookie

unread,
Aug 9, 2010, 1:41:01 AM8/9/10
to android-ndk
Hi,
You can take a look at sample/two-libs/.
and modify the Android.mk to what you want.
Good luck.

On Aug 7, 7:17 am, Onur Cinar <onur.ci...@gmail.com> wrote:
> Hi Reddy,
>
> It would be better to keep the .a file in your project directory, since it
> will get deleted if you manually put it into the NDK's work directories.
>
> If you add the following into your Android.mk file it should be fine I
> think.
>
> LOCAL_LDLIBS += $(LOCAL_PATH)/../library.a
>
> That's how I'm linking closed-code 3rd party Android libraries into the
> project.
>
> Regards,
>
> -onur
>
> On Fri, Aug 6, 2010 at 2:40 AM, Reddy <devireddy....@gmail.com> wrote:
> > Hi,
>
> > I have an already existing Static library created in android version
> > 1.6. Now i want to use this static library in creation of Shared
> > library. Please tell me where i need to keep the Static library so
> > that the Android.mk file can access this.
>
> > /Reddy
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-ndk...@googlegroups.com<android-ndk%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages