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

Unpack the glibc-crypt and glibc-linuxthreads in the glibc-2.1.3 directory, not in /usr/src. Don't enter the created directories. Just unpack them 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 cd into that directory with:



mkdir $LFS/usr/src/glibc-build &&
cd $LFS/usr/src/glibc-build

In that directory you create a new file configparms containing the following:



# Begin configparms

slibdir=/lib
sysconfdir=/etc

# End configparms

You can create this file by simply running the following command:,



echo -e "slibdir=/lib\nsysconfdir=/etc" > configparms

The \n after slibdir=/lib is not a mistake. The \n characters will be interpreted as if the enter key was pressed.

If you're getting errors related to illegal character 45 in some variable name during the compilation, apply the Glibc patch to the glibc-2.1.3 directory by cd into the glibc-2.1.3 direcotry and running the following command:



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.

If your system had already a suitable GCC version installed, change to the $LFS/usr/src/glibc-build directory and install Glibc by running the following commands:



cd $LFS/usr/src/glibc-build &&
../glibc-2.1.3/configure \
���--prefix=/usr --enable-add-ons \
���--with-headers=$LFS/usr/include &&
make &&
make install_root=$LFS install &&
make install_root=$LFS localedata/install-locales

If your system didn't have a suitable GCC version installed, change to the $LFS/usr/src/glibc-build directory and install Glibc using the gcc-2.95.2 you just installed by running the following commands:



cd $LFS/usr/src/glibc-build &&
CC=/usr/local/gcc2952/bin/gcc \
���../glibc-2.1.3/configure --prefix=/usr --enable-add-ons \
���--with-headers=$LFS/usr/include &&
make &&
make install_root=$LFS install &&
make install_root=$LFS localedata/install-locales

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:



strings /lib/libc* | grep "release version"

The output of that command should tell you something like this:


GNU C Library stable release version 2.1.3, by Roland McGrath et al.

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



cp -av /lib/libnss* $LFS/lib

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.