where to place library files under linux

Posted on 2007-10-11
Last Modified: 2010-05-18

Is there any common place you put libraries used for developing apps under linux? When developing for win32, I  usually make a folder under C:\ called "lib". Then all users can access any library under c:\lib.

Under linux, it seems there's already a folder called "lib". Is it proper to dump my libraries into there, or should I create some separate folder to differentiate? Also, it looks like in the /usr folder on my system we have a copy of the lib folder - what is the purpose of having /lib, and then usr/lib?

Question by:DJ_AM_Juicebox
    LVL 86

    Accepted Solution

    Under Linux, that's quite similar - it *is* '/usr/lib', as you assumed above. ("Program Library HOWTO") adresses that also, I already mentioned that HOWTO in an earlier question of yours.
    LVL 86

    Expert Comment

    BTW, to reference a particular library that is not placed there, use


    to specify that directory on teh compiler's/linker's command line. As the man page says:

          -Ldir  Add  directory dir to the list of directories to be
                 searched for `-l'.

                 Use the library named library when linking.

                 The  linker searches a standard list of directories
                 for the library, which is  actually  a  file  named
                 `liblibrary.a'.   The linker then uses this file as
                 if it had been specified precisely by name.

                 The directories searched include  several  standard
                 system  directories  plus any that you specify with

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
    Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now