Basics of a C++ Development/execution environments

Assume source code, a program, has been created.

Preprocessor
The preprocessor program processes preprocessor code. It executes automatically before the compiler stage. It obeys special commands called preprocessor directives which indicate that certain manipulations are to be performed on the program before compilation. These manipulations typically consist of including other files or telling the compiler to define some code as it may be repeated and it shouldn't be stored twice.

For example, typically in files defining classes, the   #ifndef   tells the compiler to do what follows if the definition is not already in the symbol table under the given name. The symbol table is a huge data structure of every identifier in your program and everything the compiler needs to know about it. The   #define   says to define it associated with the given name as follows in the code. The   #endif   terminates the   #ifndef   directive. This is explained further via the Rational example in the Rational class header file.

Compiler
The compiler creates object code and stores it on disk. It is a special type of translator; it translates source code into machine language code (same as object code). In the beginning you will care mostly about the compiler errors, the error messages. Eventually compiler errors become no big deal, but in the beginning when you don't know all of the language, they can be confusing. If you leave off a semicolon, misspell, forget a parenthesis, mess up your curly braces, etc., you get a compiler error.

Often the compiler doesn't determine an error until it goes beyond what is really wrong, so always look at the line after the error. C++ error messages are not as clear as Java error messages. And you can get many, many of them for doing one simple thing wrong. Always correct the first error and recompile before trying to figure out the rest. Often they aren't true errors, are propogated because of the first error, and will disappear.

Linker
The linker links the object code with the libraries, creates an executable file and stores it on disk. When you refer to something in a library, the compiler leaves a hole for the address where it can be found and the linker must resolve the addressing. In other words, it must find it to create a complete executable file.

When you get a linking error, it can't find something. Usually it's a typo. Function signatures (the header) etc., must be identical to what is in the .cpp file. Also, your #includes may be wrong.

Loader
The loader puts the program in memory so the CPU can take each instruction and execute it. It will likely store new data values as the program executes.

What is the difference between a compiler and interpreter?
While a compiler translates high level language into machine code to later be loaded and executed, an interpreter takes the high level code and immediately carries out the instruction. There are also hybrid systems where high level code is translated into intermediate code (e.g., Java byte code) and then the instruction is performed by an interpreter.