Typical compilers output so called objects, which basically contain machine code augmented by information about the name and location of entry points and external calls (to functions not contained in the object). A set of object files, which need not have all come from a single compiler, may then be linked together to create the final executable which can be run directly by a user.
Modern compilers share a common 'two stage' design. The first stage, the 'compiler frontend' translates the source language into an intermediate representation. The second stage, the 'compiler backend' works with the internal representation to produce code in the output language. While compiler design is believed to be a complex task, this approach allows to exchange either the frontend or backend to retarget the compilers source and output language respectivly. This way modern compilers are often portable and allow multiple dialects of a language to be compiled.
The compiler frontend consists of multiple phases itself, each informed by formal language theory:
While there are applications where only the compiler frontend is necessary, such as static language verification tools, a real compiler hands the intermediate representation generated by the frontend to the backend, which produces a functional equivalent program in the output language. This is done in multiple steps:
Many people divide higher level programming languages into two categories: compiled languages and interpreted languages. However, in fact most of these languages can be implemented either through compilation or interpretation, the categorisation merely reflecting which method is most commonly used to implement that language. (Some interpreted languages, however, cannot easily be implemented through compilation, especially those which allow self-modifying programs.)
The so called 'Dragon Book', ISBN 0201100886 (amazon.com, search) from 1985 is considered to be the standard authority on compiler basics and makes a good primer for the techniques mentioned above.
In the recent decade a large number of free compilers and compiler development tools were developed for all kinds of languages. Some of them are considered to be of very high quality and their free source code make a nice read for everyone interested in modern compiler concepts.
See also: assembler, interpreter, linker