Home Technology What is the “build” function? Explain the mechanism and the difference from compilation

What is the “build” function? Explain the mechanism and the difference from compilation

by Yasir Aslam
0 comment

When I first used Eclipse, an integrated development environment (IDE), the first thing I was confused about was the lack of a feature named “Compile”! That was the point. At school, I learned to “compile a program to create an executable file”, but creating an executable file in an integrated development environment is a function called “build”, and I remember being confused about how it differs.

So, this time, I would like to explain the mechanism of build, starting from the difference between build and compile.

table of contents

1. 1. What is a build?

1.1 What is a build?
1.2 What is a compilation?
1.3 What is a compilation?

2. Build mechanism and flow

2.1 Perform static analysis of each source code
2.2 Perform preprocessing with preprocessor
2.3 Compile each source code
2.4 Link each object file and library

3. 3. Debugging efficiency is improved by understanding the build mechanism

1. 1. What is a build?

1.1 What is a build?

Roughly speaking, building is “analyzing the source code for problems (bugs), converting it into a file that can be executed if there are no problems, and assembling it.” However, the content may differ slightly depending on your development environment.

1.2 Difference from compilation

Hearing the above explanation, isn’t it a compilation? You may think that. To put it simply, compiling is a step in the build process.

1.3 What is compilation?

Compiling means translating in English, meaning translating source code from a human-readable and easy-to-understand programming language into a machine-readable and easy-to-understand machine language. However, a complicated program does not work just by translating the source code, so it is necessary to build the necessary set of incidental files. I would like to explain in detail in the next section.

2. Build mechanism and flow

The flow of processing being performed in the build can be represented in the following figure.

2.1 Perform static analysis of each source code

When you start the build, you first do a static analysis of the source. This static analysis is done to detect grammatical and syntactic errors, that is, to find bugs. If there is a bug, the process will stop here, compilation will not proceed, and the bug detection location will be notified and the process will end.

2.2 Preprocessing with preprocessor

If no errors are found in the source code, the next step is to preprocess for compilation in the “preprocessor”. Preprocessing includes replacing constants with numbers, deleting comments, and expanding macros.

Note that this preprocessing may or may not be performed in some languages. Typical languages ​​that use the preprocessor include C and COBOL.

On the contrary, it is possible to use the preprocessor even in a language that normally does not need to be used. For example, Java usually does not use a preprocessor, but it seems that some Java preprocessors were used for the purpose of compressing file size.

2.3 Compile each source code

After the pre-processing is finished, the next step is to compile with the “compiler”. As mentioned above, compiling means “translation” in English, and converts the source code written by humans into an object file (.o, .obj, etc.) written in a language that is easy for machines to read. ..

2.4 Link each object file and library

After compiling, the “linker” finally links each object file and library. By linking all the parts, the “executable file” is finally completed.

What is the "build" function?  Explaining the mechanism and the difference from compilation Freelance engineer project information | Professional engineer column_image6308_02

3. 3. Debugging efficiency is improved by understanding the build mechanism

Knowing what’s going on behind the build button that you’re always casually pressing is often useful, as it makes it easier to identify the cause when an error occurs. Please take this opportunity to remember how the build works.

You may also like

Leave a Comment