The compilation is done in what you have done, if you don’t have it compiled. In fact no normal compiler compiles dependencies, if he does he is not just a compiler. In general there is a system of build who does this task and in many cases needs to write scripts to specify dependencies. You can see more about Makefile: what it is, and what the purpose?. C and C++ uses Make.
For example, if I include a certain library in my program, when compiling it, I will pass it to the compiler, correct?
On the whole, yes.
But now, after compiling the program, it had worked without me having installed it on my particular library machine?
It depends. If it’s something that’s already in the operating system, you don’t need it. If it is something that only serves for your application then, in general, you have to send it together or pre-install it. But this is not worth generating a monolithic executable, see more in What is the difference between static and dynamic linkage?.
May also be useful: What’s the difference between DLL and lib?
Thank you, that’s exactly what I needed! :)
– Richard Henrique