How Exe file is Generated by VS2005 C++ Project?

Let us consider a simple example. Say, you have exe project, and the project has three header files and three implementation files. After the coding done without any error, you build the project. The build project operation will create the exe output. Have a look at the below picture.

 

Pic01.JPG

 

When you build the project the following actions are taken by the development IDE (Say VS2005):

 

1)      The compiler conducts a pre-processing operation before doing its actual job of compilation. The processing is conducted on the source file; I mean the cpp files. This pre-processing replaces the macros to its content, #include header files, to its content etc.

2)      Once the above said operation is completed for the single file say a.cpp, the compiler starts compiling that file to generate the a.obj file. And this continues till all the cpp files on a specific project (Exe or dll or ocx; whatever it is) is converted to object file.

3)      Now linker comes into picture. The linker understands more robust and compact form of input that comes as object file for each compiler-processed cpp in the previous step. The linker combines all object files and generates the required binary say the exe file in our case.

 

If you we feed input to the compiler in the form of the cpp programming language and the linker actually generates the output binaries.

 

If your Solution workspace contains 57 projects with dependency properly set, the above said compilation and linking takes place for each project. When you build such big solution, just sit back and watch the output window. You will see for each project, the build operation displays cpp file processing and at the end the linker will generate the output.