When a C program is compiled, does it include all the dependencies necessary for its operation?

Asked

Viewed 60 times

0

When I compile a program in C, will all dependencies be compiled together? If not, it is possible to compile them?

For example, if I include a certain library in my program, when I compile it, I will pass it on to the compiler, correct? After compiling the program, it will work without me having installed on my particular library machine?

1 answer

0


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! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.