Learn about linking/compiling/assembly

I have a fairly solid fundamental knowledge of C and C++ as langauges, but I don't feel that I completely understand the compiling/linking/assembly process, especially the differences between libraries and executables and how they interact. I was wondering if anyone could provide several links that explain the above in relative detail.

Thanks.
Microsoft Portable Executable and Common Object File Format Specification
http://www.microsoft.com/whdc/system/platform/firmware/PECOFFdwn.mspx

An In-Depth Look into the Win32 Portable Executable File Format
http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
Why post about WinPE and COFF and not ELF on "UNIX/Linux programming?"

UNIX executable formats:
Executable and Linkable Format (ELF)
www.skyfree.org/linux/references/ELF_Format.pdf
(since AT&T UNIX System V)

AOUT (a.out) was used prior to ELF, but I can't find any information on it other than wikipedia articles.

I have a fairly solid fundamental knowledge of C and C++ as langauges, but I don't feel that I completely understand the compiling/linking/assembly process, especially the differences between libraries and executables and how they interact. I was wondering if anyone could provide several links that explain the above in relative detail.

Heres basically what happens when you compile C/C++ source code:
1. The C pre-processor replaces macros, resolves includes, etc.
2. The compiler generates assembly code for the target platform[1][2]
3. The assembler creates object files from the generated assembly language
4. The linker resolves unresolved dependencies in the object files by searching them against other object files it has stored somewhere (e.g. in /usr/lib), links the object files into one object file, and then converts that into an executable file
5. You're done.

[1]it's possible to build a "cross compiler," i.e. have an x86 C compiler produce SPARC assembly code or a compiler on windows produce ELF files and vice versa.
[2]some compilers skip this step
Last edited on
@kbw: thanks for the info, it's interesting, but not exactly what I was looking for (why I posted in UNIX/Linux :) )
@chrisname: that's definetly a large part of what I was looking for, thanks a lot. The rest was a google search away (searched "C++ statically linked library", "C++ shared library").

Thanks a lot for the responses.
Topic archived. No new replies allowed.