smilingbuddha
smilingbuddha

Reputation: 14660

question about include and library files

Hi I noticed that in the Linux file system we have 4 folders

Libraries

/usr/local/lib /usr/lib

Include files

/usr/local/include /usr/include

Now I know that while writing a C program the compiler checks these standard folders for libraries and include files in the order mentioned above.

I wanted to know why have two folders for each; 2 for lib and 2 for include. Why not just have one for each? What is the reason for this division?

Thank you.

Upvotes: 1

Views: 109

Answers (2)

aefxx
aefxx

Reputation: 25249

See this pub (search for /usr/local):

http://www.pathname.com/fhs/pub/fhs-2.3.html

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.

For a general overview consult Wikipedia:

http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

Upvotes: 2

Jack
Jack

Reputation: 133577

Usually because /usr/lib/ and /usr/includes/ are used as the main repository for the system-wide libraries and includes while the more specific /usr/local/lib and /usr/local/includes are filled by users that need to install additional libraries/headers.

This should mean that the latter ones start empty with a new OS installation and ready to be filled by custom libraries while the system ones are already full of standard libraries. In this way when you perform a system update the local folders should be kept untouched while the system-wide one are updated..

Upvotes: 1

Related Questions