I’m having trouble understanding how compilers and linkers work and the files they create. More specifically, how do .cpp, .h, .lib, .dll, .o, .exe all work together? I am mostly interested in C++, but was also wondering about Java and C#. Any books/links would be appreciated!
I’m having trouble understanding how compilers and linkers work and the files they create.
Share
There are suprisingly few books on this topic Here are some thoughts:
Do not bother withn the Dragon Book unless you are actually writing a compiler using a table driven approach. It is a very hard read abd does not cover the simplest approach to parsing – recursive descent – in any detail. Caveat: I haven’t read the leatest edition.
If you actually want to write a compiler, take a look at “Brinch Hansen on Pascal Compilers“, which is an easy read and provides the full siource for a small pascal compiler. Don’t let the pascal stuff put you off – the lessons it teaches are applicable to all compiled languages.
When it comes to linking, there are very few resources. The best book I’ve read on the subject is Linkers & Loaders.