Prebuild static libraries interdependence issue

53 views
Skip to first unread message

Shusen Wang

unread,
Jun 7, 2014, 7:11:25 AM6/7/14
to andro...@googlegroups.com
Hi,

Recently I have studied the webrtc project, and I found the prebuild static library interdependence issue. I attached the sample codes to illustrate the issue.

There are 2 folders, each folder contains 3 projects (A,BC).  A and B are static libraries. C is the dynamic library which only depends on lib B.

Folder abc :  B only depends on A.  depends on nothing.
Folder abc_interdepend :  B depends on A.  depends on B.

For C in folder abc,  even I know I have to add A to depend on, it doesn't work when I add A to C's dependence. But it works when I add A to B's dependence.   I seams like ndk doesn't support link the static lib altogether.

For C in folder abc_interdepend, according above rule, I have to add A to B's dependence, and B to A's dependence. Thus recurrence happens.  The result is the link issue.

Is there any chance to link all the prebuild libs together for ndk to ignore static libs dependence?

Can anybody help me resolve this issue? Thanks!
lib_dependence.zip

David Turner

unread,
Jun 13, 2014, 5:19:56 AM6/13/14
to andro...@googlegroups.com
On Sat, Jun 7, 2014 at 4:11 AM, Shusen Wang <gws...@gmail.com> wrote:
Hi,

Recently I have studied the webrtc project, and I found the prebuild static library interdependence issue. I attached the sample codes to illustrate the issue.

There are 2 folders, each folder contains 3 projects (A,BC).  A and B are static libraries. C is the dynamic library which only depends on lib B.

Folder abc :  B only depends on A.  depends on nothing.
Folder abc_interdepend :  B depends on A.  depends on B.

For C in folder abc,  even I know I have to add A to depend on, it doesn't work when I add A to C's dependence. But it works when I add A to B's dependence.   I seams like ndk doesn't support link the static lib altogether.

That's normal, because order is very important when linking libraries on Unix, you need to be very explicit to ensure that ndk-build will list them correctly to the linker, in this specific case:

- If B depends on A, you needs to add 'LOCAL_STATIC_LIBRARIES := a' in B's module declaration.
- If C depends on B, you need to add 'LOCAL_STATIC_LIBRARIES := b' in C's module declaration.

When doing this, ndk-build will infer that C -> B -> A and list them in the correct order to the linker.
 
For C in folder abc_interdepend, according above rule, I have to add A to B's dependence, and B to A's dependence. Thus recurrence happens.  The result is the link issue.

Is there any chance to link all the prebuild libs together for ndk to ignore static libs dependence?

Inter-dependent libraries are generally not a good idea, but you could use 'LOCAL_WHOLE_STATIC_LIBRARIES := a b' in your module C's declaration to work-around this. This tells the linker to always link the content of both libraries to libC.so.
 
Can anybody help me resolve this issue? Thanks!

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.

Swetha Setty

unread,
Jun 13, 2014, 2:10:29 PM6/13/14
to andro...@googlegroups.com

Hi,

You have to remove recurring dependency for status Libs to link.
Have another library, to separate out the inter dependency and try it out.
That's the best shot!!

- Swetha

--
Reply all
Reply to author
Forward
0 new messages