Let's say I have libA.so with version 1.1 and 1.2, both have the same symbols defined.
what happens if myApp need a symbol from libA but mistakenly linked both versions:
ld -o myApp -Lpath -lA_1_1 -lA_1_2
Am I right it will use symbols from the first one as long as it can find it?
Yes, in general. And that might not be what you want.
If a function
foo()
inlibA_1_2
calls another public function in the library,bar()
, then it will use the symbol fromlibA_1_1
, which might do the wrong thing (for example if v1.2 of the library was changed so thatfoo()
expectsbar()
to deallocate some memory, but the v1.1 version ofbar()
doesn't do that).