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 libraries it was linking to. Surprisingly, there were a lot, none of them had I manually selected in my makefile, nor using pkg-config --libs
.
I started reading about shared libraries, and made a little example to solve my doubts. However, I have this question:
why some libraries need you to add the dependencies in your makefile (either manually or using a script like
pkg-config
) and other libraries automatically link their dependencies?
When you're creating your dynamic library, is just as easy as adding the proper -ldependency
options in the g++ -shared ...
command to avoid the user the hassle of manually adding the dependencies later on. Why many of the available libraries don't do that?
I guess it must be related to the ability of fine tuning which libraries get linked and such.