0

How can I get access to the source code of standard shared libraries?

Braiam
  • 67,791
  • 32
  • 179
  • 269
Hja
  • 13
  • 1

1 Answers1

2

It depends on the concrete library you're looking for.

As an example, let's take a look at /usr/lib/liba52-0.7.4.so (this was simply the first file in my /usr/lib directory).

First, let's find out what package the file belongs to:

$ dpkg -S /usr/lib/liba52-0.7.4.so
liba52-0.7.4: /usr/lib/liba52-0.7.4.so

So now we know that the package name is liba52-0.7.4. To download the source code, use

$ apt-get source liba52-0.7.4

Note: no need to use sudo. The latter command will create a directory a52dec-0.7.4/ in the working directory. This contains the source code.

Malte Skoruppa
  • 13,196
  • 5
  • 57
  • 65
  • What if it returns two or more packages? and is there any directory inside the Ubuntu source code for these library-related packages? Thanks again – Hja Jan 08 '14 at 19:47
  • A single file (such as a shared library) should only belong to a single package, not more. I do not understand your second question. As I said, the apt-get source command will create a directory with the package's source code inside the working directory, that is, the directory you're currently in at the moment where you type in the command. – Malte Skoruppa Jan 08 '14 at 19:51
  • It is weird since running dpkg -S /usr/lib/libical.so.0 on my laptop returns two package names while running it on my desktop returns only one package name...any way... In second question, I am asking whether I can find the packages for these libraries inside an Ubuntu installation disk containing the source code or not? If so, please let me know where... Thank u once again – Hja Jan 08 '14 at 19:56
  • Which two package names do you get? For the library you mentioned, the corresponding package is libical0. Concerning your second question, no, the source code of libraries is not contained inside the Ubuntu installation disk. – Malte Skoruppa Jan 08 '14 at 19:58
  • /usr/lib/libical.so.0 and /usr/lib/libical.so.0.48.0 – Hja Jan 08 '14 at 20:03
  • Are they the same? – Hja Jan 08 '14 at 20:03
  • Those are file names. Both belong to the same, single package, namely libical0. In fact, /usr/lib/libical.so.0 is simply a symbolic link to /usr/lib/libical.so.0.48.0. While a single file only belongs to a single package, a single package usually contains several files. – Malte Skoruppa Jan 08 '14 at 20:05