Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
what are libraries and whats the equivalent of this in windows. whats it function? i'm getting confuse as i'm learning yet linux gurus in cbt nuggets never even teach what ...
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    55

    Question what are libraries?



    what are libraries and whats the equivalent of this in windows.

    whats it function?
    i'm getting confuse as i'm learning yet linux gurus in cbt nuggets never even teach what this is for and what it do.

    so can you tell me in such a simple thing that a a person with a minimum knowledge in windows can understand please?

  2. #2
    Just Joined!
    Join Date
    Aug 2009
    Posts
    5
    Quote Originally Posted by enhu View Post
    what are libraries and whats the equivalent of this in windows.

    whats it function?
    i'm getting confuse as i'm learning yet linux gurus in cbt nuggets never even teach what this is for and what it do.

    so can you tell me in such a simple thing that a a person with a minimum knowledge in windows can understand please?
    Static Lib's:
    A static library is an archive whose members are object files. A library makes it possible for a program to use common routines without the administrative overhead of maintaining their source code, or the processing overhead of compiling them each time the program is compiled.

    Shared Lib's:
    Each program using routines from a static library has a copy of them in the executable file. This wastes disk space and (if more than one such program is in use at the same time) RAM as well. Also, when a static library is updated, all the programs using it must be recompiled in order to take advantage of the new code. When a program uses a shared library instead, the program binary does not include a copy of the code, but only a reference to the library. The run time loader, ld.so, finds the library and loads it into memory at the same time as the program.

  3. #3
    Just Joined!
    Join Date
    May 2009
    Posts
    55
    dyou mean those program will keep referencing these libraries every time they'll run or even just open a file? - this is the only thing i can come up with as you explained it.

    now, why do some edit these libraries? what are the reasons?

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,204
    Okay.

    So when you write a program, you generally segment it into areas of functionality called functions. For instance, you might have a function that you invoke to read from a file.

    It would be very annoying if every programmer had to write a function to read from a file, because this is very common. Therefore, what we do instead is put this function into a library. A library is a third-party collection of functions that any program can use.

    There are two ways for a program to interface with a library. One is called "static linking". In the case of static linking, the program actually contains a copy of the library. When you run the program, you are including the library, so the functions in the library are usable.

    The more popular method is called dynamic linking. In this method, when you run a program, it actually looks on your computer for the desired library and loads it. So if you have five programs all using the same library, you only actually need one copy of it on your computer (as opposed to static linking, where each program would include its own copy).

    To give you some examples of libraries:

    libc: This contains common pieces of functionality, like reading input from files and writing output to the terminal.

    libm: This contains more complicated mathematical routines, such as rounding numbers, doing exponents, logarithms, sine, cosine, etc.

    libgtk: This contains functions for creating graphical user interfaces with the Gtk+ toolkit (the toolkit used by all Gnome applications).

    I hope that this makes a bit more sense.

    As for why you might want to edit a library, perhaps you are adding more functions to the library, or making existing routines more efficient. For instance, a library that offered the ability to sort a list of numbers might be changed from using insertion sort (very inefficient) to using quicksort (very efficient).
    DISTRO=Arch
    Registered Linux User #388732

  5. #5
    Just Joined!
    Join Date
    May 2009
    Posts
    55
    thank you.

    it becomes clearer now.
    its really a blur in my mind as i'm getting familiar with its cli with the help of those tuts.

    thanks

  6. #6
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,653
    Just to add on, Windows uses shared libraries as well, called dynamic-link libraries. These are files with the .dll extension.

  7. #7
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    913
    Quote Originally Posted by reed9 View Post
    Just to add on, Windows uses shared libraries as well, called dynamic-link libraries. These are files with the .dll extension.
    One difference between Windows and Linux libraries is that in Windows, the libraries are mostly proprietary: they belong to the company that wrote the program. So each program comes with its own set of libraries. If another company writes a program which does the same sort of job, they can't use their rival's library; they have to write their own. It's like reinventing the wheel over and over.

    In Linux, the libraries are free software so any programmer can use them. If I want to write a program to do a particular job, I can find out if there are suitable libraries available and use them in my program. Every library comes with documentation so that would-be programmers know exactly what functions the library contains and how to call them.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  8. #8
    Just Joined!
    Join Date
    May 2009
    Posts
    55
    thanks for those info.

    would it also cause a conflict if i have installed a software and that this software had its own library with it in the rpm package. yet there are already available libraries for it?


    sorry. really newbie here.
    haven't even got to the point where I've installed a software yet.

  9. #9
    Just Joined!
    Join Date
    May 2009
    Posts
    55
    and how dyou know whether a software you wanted to install already have libraries ready for it.

  10. #10
    Just Joined! teenytinylinuxgrl's Avatar
    Join Date
    Jul 2009
    Location
    florida
    Posts
    78
    Synaptic, as I understand it, checks dependencies needed when it installs a program. If the library is already there, it is not duplicated. The new program has access to it anyway.

    Amy

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •