If you check the lib directories you will see that there are multiple symlinks.
So for a certain library it could look like this:
libname.so -> libname.so.1
libname.so.1 -> libname.so.1.8
libname.so.1.8 -> libname.so.1.8.4
libname.so.1.8.4
Library vendors normally give certain API compatibility for their version jumps. So as a developer you could link e.g. against libname.so.1
is you know that the library vendor would only add features and do bugfixes within 1.x.y
.
Or you could link against libname.so.1.8
if you want to be more specific about the installed version.
The package provided by the distro (or the vendor) normally provide those version for which breaking changes in the API exists.
So as a library/application developer, you will check the version scheme your dependencies use, and you will link in the least restrictive way that will guarantee you stability and compatibility.
The same will be true for the c++ runtime library:
libstdc++.so -> libstdc++.so.6.0.28
libstdc++.so.6 -> libstdc++.so.6.0.28
libstdc++.so.6.0.28
The compiler version is not really relevant, relevant is the runtime library, that one needs to be ABI compatible with the binary that is installed.
GCC: ABI Policy and Guidelines
“ library API + compiler ABI = library ABI ”
The library ABI is mostly of interest for end-users who have unresolved symbols and are linking dynamically to the C++ Standard library, and who thus must be careful to compile their application with a compiler that is compatible with the available C++ Standard library binary. In this case, compatible is defined with the equation above: given an application compiled with a given compiler ABI and library API, it will work correctly with a Standard C++ Library created with the same constraints.
[…]
Binaries with equivalent DT_SONAMEs are forward-compatibile: in the table below, releases incompatible with the previous one are explicitly noted. If a particular release is not listed, its libstdc++.so binary has the same filename and DT_SONAME as the preceding release.
So all libstdc++.so.x
version are forward compatibility if not mentioned otherwise. So if you build you application against libstdc++.so.6.0.1
, it would be compatible with libstdc++.so.6.0.28
, so you could link against libstdc++.so.6
.