Where does Ubuntu store its library files?

I want to add my own library to use in c compiling, but don't really know where ubuntu stores it.


Solution 1:

Based on your comments to your question, I think what you are really asking is "How do I install a custom library I wrote and where should I put it?"

In general, things built locally for others on the machine to user are put into the /usr/local tree. The header file should go into /usr/local/include. The compiled library should go into /usr/local/lib. The .c file is not part of the library, it is part of the source and not something normally not installed for the use of the end user. You will need root access to put files in either of these locations.

To build the library, you will need to build first decide if you want a static or dynamic (shared) library. More information on creating a shared library can be foundin section 3.4, Creating a Shared Library at http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html. (They also have recommendation about where to put stuff -- most developers will have an an opinion or three :-) )

Solution 2:

Depending on library, ubuntu stores its libraries mainly in three locations

  1. /lib
  2. /usr/lib
  3. /usr/local/lib

Following is from File System Hierarchy Standard

/lib

The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin.

/usr/lib

/usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts. [22]

Applications may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the application must be placed within that subdirectory.

/usr/local/lib contains local libraries i.e one specific for this system but I can not find references to /usr/local/lib in FHS, it only contains explanation for /usr/local.