Noticias - 31/05/2025 | Madre mía que caló hace 🥵          🌍          News - 31/05/2025 | Damn it's so hot 🥵

viernes, 11 de julio de 2025

Is there an actual difference between compiling and building?

Both terms are used daily in software development environments: "F***, compiling takes forever," or "Did you build after that last change?"... In reality, they're used pretty much the same way — and I’m guilty of that too. But is it actually correct to refer to compiling and building a project as if they meant the same thing?

Since this isn’t one of those commercial blogs with ads and SEO nonsense, I can give you the answer straight away, hehe. No, they’re not the same, even though they’re tightly related. Compilation is a process where a source code file is transformed into machine code (understandable by the CPU), and this generates one or more temporary object files (*.o), depending on how many source files need to be processed.

These object files are then used as input for another process called linking. Compilation and linking are two of the key gears in a bigger functional mechanism we commonly refer to as "building".

[ 50%] Building CXX object CMakeFiles/my_program.dir/src/main.cpp.o 
/usr/bin/g++ -I../include -o CMakeFiles/my_program.dir/src/main.cpp.o -c ../src/main.cpp 
[100%] Building CXX object CMakeFiles/my_program.dir/src/utils.cpp.o 
/usr/bin/g++ -I../include -o CMakeFiles/my_program.dir/src/utils.cpp.o -c ../src/utils.cpp 
[100%] Linking CXX executable my_program 
/usr/bin/g++ CMakeFiles/my_program.dir/src/main.cpp.o CMakeFiles/my_program.dir/src/utils.cpp.o -o my_program 

The example above shows a typical, simplified terminal output produced when building a project with CMake and Make. You can see how files like main.cpp and utils.cpp are compiled into their respective object files, which are later linked into the final executable my_program.

It might catch your eye that the process says Building while transforming a source file into an object — even though I just explained that this step is called compiling, not building.

So... is CMake wrong and am I a genius? I highly doubt the first part. The thing is, Make doesn’t specifically say Compiling because it uses Building as a general status label for the entire build process, while also indicating the type of file being generated (object) and the language (CXX = C++).

No hay comentarios:

Publicar un comentario