I'm trying to understand how Linux works and how to build modules.
So far I saw that Linux headers are stored in /usr/include
and that the compiled implementation of these interfaces are located in /usr/lib/x86_64-linux-gnu
. I have a few questions:
How does Linux or any C program know where to look for the headers and the .so files? Is there a file where this is defined? Is it possible to modify these references in case I wanted to add another default sources or headers folder (just to horse around)?
How are conflicts avoided? For example, in the
libprocps-dev
there is a header file/usr/include/proc/numa.h
with the definitionvoid numa_uninit (void);
. The implementation of this file is in/usr/lib/x86_64-linux-gnu/libprocps.so
. What if someone also compiled another .so file with the same function definition but with another implementation (or code) and added it to/usr/lib/x86_64-linux-gnu
? How would the Linker know which is the proper .so file that has to be linked to that header definition?
Thanks.