Understanding C Runtime

I am learning C language and I have a question. If I compile and make an executable file for C program in BorlandC on one Windows PC, then transfer this file to another Windows PC that does not have a compiler, how it runs where there is no C runtime, and how it works memory management

+4
source share
2 answers

You can do this relatively painlessly if you use static binding. This means that the runtime libraries are tied to your executable when you compile / link (on your computer), rather than loading dynamically at runtime (on another computer).

If you use dynamic linking, libraries should be available at runtime in which you run the code, so the loader (part of the OS) can find them and link to them.

For a good explanation of the static / dynamic link differences see here .

+4
source

For C, a shared library called "libc" is often used, which must be shipped with your OS. Memory management is carried out by your own program using malloc (calloc, etc.) and for free. They are also part of the library.

Also note that the compiler and the runtime are two different things (you can install the executable without the compiler), although sometimes they are combined together.

+2
source

All Articles