I want to add my own library to use in c compiling, but don't really know where ubuntu stores it.
|
|
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 :-) ) |
|||
|
|
|
Depending on library, ubuntu stores its libraries mainly in three locations
Following is from File System Hierarchy Standard /lib
/usr/lib
/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. |
||||
|
|
|
Ubuntu follows Filesystem Hierarchy Standard (http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard), regular applications libraries should be stored under /usr/lib . Please note that developing/managing libraries is not a trivial subject, you should read some more detailed documentation, here is a nice tutorial: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html |
|||
|
|
|
You should tell the compiler, where it can find your library. Assumed, the path to your library is "/path/to/lib/libfoo.a", you could compile and link your program "hello.c" like this:
This is not specific to Ubuntu, actually all C-compilers I know support those flags. |
|||
|
|