I can link my example.o using this command with no problem
gcc example.o -o example.exe
but if I manually link it using ld, I get many errors:
ld example.o -o example.exe
example.o:example.c:(.text+0x1d7e5): undefined reference to `strcmp'
example.o:example.c:(.text+0x1d9b6): undefined reference to `_ftime'
example.o:example.c:(.text+0x1dcbd): undefined reference to `strchr'
example.o:example.c:(.text+0x1df7f): undefined reference to `strtoul'
...
How does gcc invoke the linker and link the object file into an executable?
The answer is more complex than you imagine.
Run
to understand what is happening
The gory details are operating system specific. On Linux, it silently loads
crt*.oobjects (containing the_startassembly code calling yourmainetc etc…) and the C library. I have no idea of what your platform is doing; I never compiled on Windows.