Installing Glibc

A note on the glibc-crypt package

An excerpt from the README file that is distributed with the glibc-crypt package:

The add-on is not included in the main distribution of the GNU C library because some governments, most notably those of France, Russia, and the US, have very restrictive rules governing the distribution and use of encryption software. Please read the node "Legal Problems" in the manual for more details.

In particular, the US does not allow export of this software without a licence, including via the Internet. So please do not download it from the main FSF FTP site at ftp.gnu.org if you are outside the US. This software was completely developed outside the US.

"This software" refers to the glibc-crypt package at ftp://ftp.gwdg.de/pub/linux/glibc/. This law only affects people who don't live in the US. It's not prohibited to import DES software, so if you live in the US you can import the file safely from Germany without breaking cryptographic laws. This law is changing lately and I don't know what the status of it is at the moment. Better be safe than sory.

Installation of Glibc

Copy the Glibc-crypt and Glibc-linuxthreads archives into the unpacked glibc directory. Copy the glibc-2.1.3-ctype.patch file to $LFS/usr/src

Unpack the glibc-crypt and glibc-linuxthreads archives there, but don't enter the created directories. Just unpack and leave it with that.

A few default parameters of Glibc need to be changed, such as the directory where the shared libraries are supposed to be installed in and the directory that contains the system configuration files. For this purpose you need to create the $LFS/usr/src/glibc-build directory and in that directory you create a new file configparms containing:



# Begin configparms

slibdir=/lib
sysconfdir=/etc

# End configparms

If you're getting errors related to illegal character 45 in some variable name during the compilation, apply the Glibc patch.

Install this patch by running the following command:



root:glibc-build# patch -Np1 -i ../glibc-2.1.3.patch

Please note that the configure script of Glibc can complain about certain files in the /usr/include directory being too old and will be replaced, or that some symlink is not supposed to be there anymore (like the /usr/include/scsi symlink that's present on older Linux systems). If it asks you to move a symlink like scsi out of the way, please do so. If it says it will replace old files by the newer Glibc files you can ignore that. Glibc does not know that it will end up on $LFS when the configure script is run.

Change to the $LFS/usr/src/glibc-2.1.3 directory and install Glibc by running the following commands if your system already had a suitable GCC version installed:



root:glibc-2.1.3# patch -p1 < ../glibc-2.1.3-ctype.patch
root:glibc-2.1.3# cd ../glibc-build
root:glibc-build# ../glibc-2.1.3/configure --prefix=/usr --enable-add-ons \
> --with-headers=$LFS/usr/include
root:glibc-build# make
root:glibc-build# make install_root=$LFS install
root:glibc-build# localedef -i en_US -f ISO-8859-1 en_US

In the above localedef command you will have to replace "en_US" and "ISO-8859-1" with the proper values for your localization needs. You can find out what's available by looking in the /usr/share/locale directory.

Change to the $LFS/usr/src/glibc-build directory and install Glibc by running the following command if your system did not already have a suitable GCC version installed and you just installed GCC-2.95.2 on your normal Linux system a little while ago:



root:glibc-2.1.3# patch -p1 < ../glibc-2.1.3-ctype.patch
root:glibc-2.1.3# cd ../glibc-build
root:glibc-build# CC=/usr/local/gcc2952/bin/gcc \
> ../glibc-2.1.3/configure --prefix=/usr --enable-add-ons \
> --with-headers=$LFS/usr/include
root:glibc-build# make
root:glibc-build# make install_root=$LFS install

Copying old NSS library files

If your normal Linux system runs glibc-2.0, you need to copy the NSS library files to the LFS partition. Certain statically linked programs still depend on the NSS library, especially programs that need to lookup usernames,userid's and groupid's. You can check which C library version your normal Linux system uses by running:



root:~# ls /lib/libc*

Your system uses glib-2.0 if there is a file that looks like libc-2.0.7.so

Your system uses glibc-2.1 if there is a file that looks like libc-2.1.3.so

Of course, the micro version number can be different (you could have libc-2.1.2 or libc-2.1.1 for example).

If you have a libc-2.0.x file copy the NSS library files by running:



root:~# cp -av /lib/libnss* $LFS/lib

There are a few distributions that don't have files from which you can see which version of the C Library it is. If that's the case, it will be hard to determine which C library version you exactly have. Try to obtain this information using your distribution's installation tool. It often says which version it has available. If you can't figure out at all which C Library version is used, then copy the NSS files anyway and hope for the best. That's the best advise I can give I'm afraid.

Contents

The Glibc package contains the GNU C Library.

Description

The C Library is a collection of commonly used functions in programs. This way a programmer doens't need to create his own functions for every single task. The most common things like writing a string to your screen are already present and at the disposal of the programmer.

The C library (actually almost every library) come in two flavours: dynamic ones and static ones. In short when a program uses a static C library, the code from the C library will be copied into the executable file. When a program uses a dynamic library, that executable will not contain the code from the C library, but instead a routine that loads the functions from the library at the time the program is run. This means a significant decrease in the file size of a program. If you don't understand this concept, you better read the documentation that comes with the C Library as it is too complicated to explain here in one or two lines.