On Linux, I’ve built two binaries, A and B, on the same machine. I take them to another machine with a slightly older libstdc++ installed. When I run ldd -v on binary A I get this:
libstdc++.so.6 (CXXABI_1.3) => /usr/lib64/libstdc++.so.6
libstdc++.so.6 (GLIBCXX_3.4) => /usr/lib64/libstdc++.so.6
When I run ldd -v on binary B I get this:
libstdc++.so.6 (CXXABI_1.3) => /usr/lib64/libstdc++.so.6
libstdc++.so.6 (GLIBCXX_3.4.15) => not found
libstdc++.so.6 (GLIBCXX_3.4) => /usr/lib64/libstdc++.so.6
Note the dependency for GLIBCXX_3.4.15 is not found. This makes sense because the installed libstdc++ only has support for up to GLIBCXX_3.4.10.
The question is: by what mechanism does ldd determine that binary B depends on GLIBCXX_3.4.15? More importantly, how do I determine what code is causing this dependency?
If you run
nmon your executables, you’ll see a large number of symbols, some of which are undefined (you can tell these as they are blank in the first column and have aUin the second column ofnm‘s default output.)Some of these symbols will have
@@whateversuffixes on them. Those suffixes are the version dependencies of those symbols, and if you look for@@GLIBCXX_3.4.15in your binary B, that should tell you which specific symbols are causing you to have that version dependency.