On Friday, 7 April 2017 at 07:15:44 UTC, rikki cattermole wrote:
I'm going to give you a very bad but still a good place to
begin with explanation.
So, what is an executable? Well in modern operating systems
that is a file with a very complex structure inside, like
PE-COFF or ELF. It has a bunch of things as part of this, a
dynamic relocation table, sections and symbols.
Now, there is a very important symbol it provides a "main"
function. Normally the libc takes ownership of this and then on
calls to the c-main that we all know and love (druntime uses
this and then passes it to another symbol called _Dmain).
What is the difference between a shared library and an
executable? Well not much, no main function for starters
(although Win32 based ones do have something like it in its
place) and a couple of attributes stored in the file.
Executables like shared libraries are final binaries, they
cannot be further linked with, at least with the most common
formats + linkers anyway.
You asked about the difference between a static library and a
shared library, it isn't quite the right comparison. You should
be asking about static libraries versus object files. In
essence a static library is just a group of object files. Not
too complicated.
Ok, but what about Go? I have heard that it's compile all code to
single exe? What is the way it's done there?