Installing Glibc

Installation of Glibc

Unpack the glibc-crypt and glibc-linuxthreads in the glibc-2.1.3 directory, not in $LFS/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 by running the following:



cat > configparms << "EOF"
# Begin configparms

slibdir=/lib
sysconfdir=/etc

# End configparms
EOF

Before we actually install Glibc you need to unpack the Glibc patch file.

Please note that the configure script of Glibc may 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 ../glibc-2.1.3 &&
patch -Np1 -i ../glibc-2.1.3.patch &&
cd $LFS/usr/src/glibc-build &&
../glibc-2.1.3/configure \
���--prefix=/usr --enable-add-ons \
���--with-headers=$LFS/usr/include \
���--libexecdir=/usr/bin &&
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 ../glibc-2.1.3 &&
patch -Np1 -i ../glibc-2.1.3.patch &&
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 \
���--libexecdir=/usr/bin &&
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 Glibc-2.0.x installed on your starting distribution, copy the NSS library files by running:



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

Command explanations

patch -Np1 -i ../glibc-2.1.3.patch: This applies a patch that fixes a minor bug in Glibc. Glibc defines a few variables names with illegal characters in the name. Bash-2.03 and older don't complain about that but Bash-2.04 does and won't compile Glibc properly.

--enable-add-ons: This enabled the add-ons that we install with Glibc: linuxthreads and crypt.

--with-headers=$LFS/usr/include: This makes Glibc use the kernel header files on our LFS system and not the kernel header files from your starting distribution which may be out-of-date or modified.

make install_root=$LFS: This is the Glibc way to specify the equivalent of --prefix=.

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.