What are the different phases or stages involved in builing an executable (compilation,linking...)? is it differen in .Net application and windows application
For C++, the preprocessor does a pass, next the compiler, then build resources (if windows application), then linking.
Here's the whole thing, up to a running application, considering just the compiler stuff.
- code program
- compile individual files to object (.o or .obj) files
- link files into an executable (a.out file or .exe)
Run the executable, which then
- relocates and loads the image into an address space
- resolves links to dynamically linked libraries (DLLs or .so's)
- set the program counter to the entry point in the setup code, which does some initializations and then
- call the
main()
routine.
Windows resource files are really just compiled into a binary form so they can be included into the executable as data. There were reasons for that back in the days of Windows 3.0, but I think now it's just a historical holdover.
The Dotnet code gets compiled to IL (intermediate Language). But unlike some other languages this intermediate code is not interpreted instead it is compiled again to get native code. This extra layer is necessary to give code portability. This process is done only once and only the required block of code gets compiled upon need. Hence the first run is always slower as the code is also getting translated to native code.