Imagine we have an executable exe that depends on shared library foo, which in turn depends on shared library bar: exe needs libfoo.so and foo needs libbar.so. Then, bar is changed in a source-compatible manner (i.e. API unchanged), but not in a binary-compatible manner (i.e. ABI changed). We must therefore relink (or face segmentation faults).
The question is: What exactly should be recompiled/relinked?
Let me make that a little more specific. To link exe, we need not add the compiler option "-lbar", whereas we do need that option for linking foo:
gcc -fPIC -shared -I. -Ibar -lbar -o libfoo.so foo.o
gcc -fPIC -I. -Ifoo -Ibar -lfoo -o exe exe.o
Therefore, is it sufficient to relink foo, and leave exe as is?
Do foo and exe also need recompilation (if bar is changed, but its API was unchanged)?
Lastly, I have tried leaving foo unchanged, but relinked exe with the added "-lbar" compiler option:
gcc -fPIC -I. -Ifoo -Ibar -lfoo -lbar -o exe exe.o
This did eliminate the segmentation fault, which could imply that everything is then correctly linked... or it could by shear luck (because segmentation faults do not always occur, even though there is an inherit memory problem).
- Is it allowed to do that, i.e. leave foo unchanged, but explicitly link exe against bar?