I was working with SFML, I compiled a little test program and added the linkage option -lsfml-audio
. Then, I used ldd ./program
to see the dynamic
Shared libraries will generally link in their dependencies. However, static libraries are not capable of doing so. pkg-config --libs
often includes all dependencies (direct and indirect) so that you can switch to static compilation by simply adding -static
without having to add additional library dependencies as well.
Note that these excess direct dependencies are considered unwanted in some cases (eg, debian tries to avoid them in packaged binaries, as they make library soname transitions more traumatic than necessary). You can instruct the linker to strip direct dependencies from the final executable that aren't needed with the -Wl,--as-needed
flag.