Target code files, executables, and libraries
The basic strategy of C programming is to use a program to convert a source code file into an executable file that contains machine language code that can be run. C in two steps to complete this work: Compile and link. The compiler translates the source code into intermediate code, which the linker combines with other code to generate the executable file. C using this method, which is divided into two parts, makes the program easy to modularize. We can compile each module separately and then use the linker to combine the compiled modules. This way, if you need to change a module, you do not have to recompile all other modules. At the same time, the linker combines its own program with the precompiled Library code. Intermediate files are available in the form of multiple choices. The most general choice of this, but also most of the C Programmer's Choice, is to convert the source code into a machine language code, the results are placed in a target code file (referred to as the target file). Although the target file contains machine language code, the file does not run yet. The destination file contains the conversion result of the source code, but the result of the conversion is not a complete program. One of the missing first elements in the target code file is the start-up code, which is equivalent to the interface between your program and the operating system. The second element missing in the target code is the code for the library function. Almost all C programs take advantage of library functions contained in standard C libraries. For example, the printf () function, where the target code file does not contain the code for this function, contains only instructions that declare the use of the printf () function. The actual code is stored in the library. The library file contains the target code for many functions. The purpose of the linker is to combine the 3 elements (the target code, the standard boot code of the system, and the library code) and store them in a single file to execute the file. For library code, the linker extracts only the code we need to use the function in our code from the library. In short, both the target file and the executable file are made up of machine language directives. But the target file contains only the code that was written by itself into the machine language, and the executable file also contains the machine code that we used to write the library routines and the startup code
Target code files, executables, and libraries