Assembly or compilation

I have a theoretical question about the difference between compilation and assembly. I program in a C ++ project, which takes a long time to build, so I said that you only need to build in cases where "I modified any header file." It's true? If I add a new attribute to the header file, then do I need to build? Not enough compilation?

Thanks!

+7
source share
6 answers

"Construction" is an indefinite term that usually means the whole process, preprocessing, compilation, and binding. Which parts of these processes need to be redone after changing the source depends on what has changed. If you have changed only one .cpp source, just recompile it and relink the objects. If you change the .h header, all source files containing this header must be recompiled, which is usually expensive, since project-related headers are usually included in many source files.

In short, if you made changes to the source, all the files affected by this should be recompiled, and the entire binary should be re-linked.

+15
source

Compilation is the conversion of source code to object code.

Linking is a combination of object code with libraries in a raw executable file.

Building is a sequence consisting of compiling and linking, possibly with other tasks, such as creating an installer.

taken from What is the difference between compilation code and executable code?

Therefore, you only need to (re) compile the object code that is older ("was edited recently") than the source file to link the executable file that contains the latest changes in your program. In fact, this is how make decides whether to create a file.

+7
source

Compilation is the process of converting high-level code to machine-level code

Building is the process of converting a high-level language to an executable file. This will be related to compilation and linking.

If you change the header file, the header file can affect several C ++ files, and therefore, to get the final executable, you need to create it

There is no use in compiling, because it does not give a final explainable and, therefore, you always need to build.

+6
source

Build is the complete process of converting source code to executable, since C ++ compilation is converting source code to object code. In the assembly, C ++ code will be compiled, and then you will need other steps, including the link phase, to create the executable. The assembly may also include other steps, for example. preprocess or generate source code files before compilation.

Performing a build only in cases where “I have changed any header file” simply means that only files that are included are compiled (directly or through other included files) and then all the objects are connected. Ina a “full” build of all files will be compiled, so this will reduce the number of files to be compiled and reduce the overall build time.

If you change the header file, then you need to compile, the compilation will simply create a new object file, which is not yet part of the executable file.

+2
source

Compilation is just one of the steps in the construction. Every time you need to recompile, you will need to rebuild.

Compilation simply takes the source files and their included header files and generates an object file for each source file. Building also links these files together to create your executable. Therefore, if you modify the source file, you need to build it if you want the new executable to be tested. Compilation will just help you with this.

+1
source

I'm not sure I fully understood your question.

Compilation is only part of the build process (which consists of preprocessing, compilation, linking, and possibly others). It creates object files, which the linker then associates with the executable, so compilation is not enough.

If your question really is whether you should run a complete build of your software, sometimes you don’t need to, if you only changed the implementation files (.cpp), but if you also changed the declarations (i.e. the headers) then you most likely you will need to do this. In any case, you will have to completely create the affected component, and not just compile it.

+1
source

All Articles