Object files store your compiled code, but they themselves are not executed. The task of the linker is to take all the object files that make up the program and combine them into a whole. This includes resolving links between object files ( extern
characters), checking for the main()
entry point (for C programs), etc.
Since each source file (.c or .cpp) is compiled into a separate object file, which is then read by the linker, changes to one C file mean only what can be recompiled, create a new object file, which is then linked to existing object files in a new executable file. This speeds up development.
UPDATE: As indicated in another answer, the “crt.o” object files contain the C r un t code, which is considered necessary by most C programs. You can read the gcc linker options and find the --no-stdlib
, this will tell gcc. that your particular program should not be associated with standard C.
source share