I link with two different shared libraries. Both libraries define some symbols that share a name but have different implementations. I can't make each library use its own implementation over the other.
For example, both libraries define a global function bar()
that each calls internally. Library one calls it from foo1()
and library two calls it from foo2()
.
Lib1.so:
T bar
T foo1() // calls bar()
Lib2.so:
T bar
T foo2() // calls bar()
If I link my application against Lib1.so and then Lib2.so the bar implementation from Lib1.so is called even when calling foo2()
. If on the other hand, I link my application against Lib2.so and then Lib1.so, then bar is always called from Lib2.so.
Is there a way to make a library always prefer its own implementation above any other library?