C Basics-Target code files, executables, and libraries

Source: Internet
Author: User

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 in the code to write the library routines and startup code.

C Basics-Target code files, executables, and libraries
Http://bbs.elecfans.com/jishu_467127_1_1.html
(Source: China Electronic Technology Forum)

C Basics-Target code files, executables, and libraries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.