Shared libraries are fun. The concept is simple in theory: we move a piece of code out of the main application into a separate (dynamically loadable) binary and nothing changes:
In practice we get two moving parts where each could be updated separately. People still don’t agree if shared libraries are a net win or a net loss as a concept :)
When you maintain both application and library as a single code base the difference does not really matter. Things get interesting when library starts it’s own life as a separate project and gets it’s own dependencies over time.
What if we want to use two different versions of the same library project within a single application. Say, use gtk-2 and gtk-3 together or ffmpeg-4 and ffmpeg-5.
The important bit here is fprintf (stderr, “lib_name() = %s”, lib_name());. The rest is convenience debugging to see what libraries are loaded into address space.
Note: lib_name() returns two very different results. And that is for a program that is linked against the same set of libraries and headers in both cases!