A fellow student asked me how to obtain the source code of libc on Ubuntu 9.10 as part of a linux course we are taking together. This is the email reply that was written for him.
Hello ____
To get the source code of libc please read and apply the following steps.
First you will needs to enable source repositories.
Please follow this link:
help.ubuntu.com/community/Repositories/Ubuntu#Ubuntu%20Software%20Tab. Make sure to select the "Source Code" option. You have now taught the system about the location of the source files and how it should download them for you.
Now, as for the code, the correct method of obtaining source code for libc (or any other software in Ubuntu for the matter) is to issue:
apt-get source WANTED-PACKAGE-NAME
In case of libc that is:
mkdir sources
cd sources
apt-get source libc6
You will see several archives being download to your local computer, the end result should be a directory named
eglibc-2.10.1 which contains the actual sources of the library.
You are encouraged to try
ls inside the directory.
Also, to find the code implementation for
strtok you would use something like:
cd eglibc-2.10.1
find -name '*.c' -exec grep -H strtok {} \+
...
...
Your code is in
./string/strtok.c, enjoy :)
The source of the source code is
FSF, which is obtained freely from
http://www.gnu.org/software/libc/
BTW, you might also like to install the man pages for C development on Linux, for this issue:
sudo apt-get install manpages-dev
This will install several man pages that so that things like:
man printf (among many others) will start making sense.
To learn what was installed by a specific package, in this case
manpages-dev try
dpkg -L manpages-dev this is a very very VERY long list... so perhaps you should pipe it into less try
dpkg -L manpages-dev | less now you can easily scroll up and down the list as well as search for specific text (type
/, enter your text, hit
Enter).
When finished you would leave
less by hitting
q.
Hope you find this useful.
Welcome to GNU/Linux.
Maxim.
--
Cheers,
Maxim Veksler
"Free as in Freedom" - Do u GNU ?