I am a newbie in the programming world
My question is on how the compiler/linker such as GCC locate the appropriate library?
I know that header files (.h files) are just merely going to be extracted by the PreProcesser before compilation onto the source file.
After the preprocessing, it's just the source code with the function declarations inserted before the main() function.
When that source file is compiled successfully. Then, the Linker will link unresolved symbols with other object files or/and with the library.
How does the Linker know which object file contain the particular symbol that it was looking for ?
maybe the user manually have to include necessary object files such as,
gcc a.o b.o c.o -o output
the error will occur at Linking phase if only
gcc a.o b.o -o output was executed.
Which means we included the necessary files all into one gcc command as shown above ..
But what about #include <stdio.h> , and so on.. (defaultly included ones)..
I know that linker will search default librarys... but how does it know which .a file contains necessary .o file ?
the difference between < > , and " " for declaring header files are merely nothing, but location issue..
You can change "a.h" to <a.h> by indicating the header file location
gcc a.o b.o -o output -l. -L.
No difference between < >, " " from gcc point of view..
How does it know whether to start looking for particular .o file in the standard library, and how does it know what .a contain that .o , and so on....
And how do we always have to include our own source files in gcc compilation, while default standard library are "somehow" automatically triggered for search...
Help me on this concept...