views:

32

answers:

1

Hi, Suppose I have 2 static Libs S1 and S2 which are different versions of the same lib and have the same C (not C++) interface though implementations are different. 2 shared libs D1 and D2 each of which links to S1 or S2 only. Suppose an application A links with S2 which is the more recent of the static libs and dynamically loads both D1 and D2 with dlopen. Will D1 just use S1s functions or is there any way to enforce it to use S2s functions? Can anything go wrong in this setup?

EDIT: Is making a shared object S a good way to circumvent this problem as D1 and D2 can both link to S then?

A: 

Will D1 just use S1s functions or is there any way to enforce it to use S2s functions?

Yes, D1 will use S1 functions. No, you cannot enforce it to use S2 functions.

Can anything go wrong in this setup?

It depends on what is inside your libraries.

Didier Trosset
What do you mean by what is inside libraries? It is not clear to me.
nakiya
I mean it depends on what is inside `S1` and `S2`. If they have global static data for example, it will not be shared between the two. This may or may not be what you want.
Didier Trosset