Installing Glibc-2.2.4

Estimated build time:           46 minutes
Estimated required disk space:  350 MB

Installation of Glibc

Before starting to install glibc, you must cd into the glibc-2.2.4 directory and unpack glibc-linuxthreads inside the glibc-2.2.4 directory, not in /usr/src as you normally would do.

This package is known to behave badly when you have changed its default optimization flags (including the -march and -mcpu options). Glibc is best left alone, so we recommend you unsetting CFLAGS, CXXFLAGS and other such variables/settings that would change the default optimization that it comes with.

Install Glibc by running the following commands:

mknod -m 0666 /dev/null c 1 3 &&
touch /etc/ld.so.conf &&
cp malloc/Makefile malloc/Makefile.backup &&
sed 's%\$(PERL)%/usr/bin/perl%' malloc/Makefile > tmp~ &&
mv tmp~ malloc/Makefile &&
cp login/Makefile login/Makefile.backup &&
sed 's/root/0/' login/Makefile > tmp~ &&
mv tmp~ login/Makefile &&
mkdir ../glibc-build &&
cd ../glibc-build &&
../glibc-2.2.4/configure --prefix=/usr \
   --enable-add-ons --libexecdir=/usr/bin &&
cp config.make config.make.backup &&
sed 's/cross-compiling = yes/cross-compiling = no/' \
   config.make > tmp~ &&
mv tmp~ config.make &&
make &&
make install &&
make localedata/install-locales &&
exec /bin/bash --login

An alternative to running make localedata/install-locales is to only install those locales which you need or want. This can be achieved using the localedef command. Information on this can be found in the INSTALL file in the glibc-2.2.4 tree.

During the configure stage you will see the following warning:

configure: warning:
*** These auxiliary programs are missing or too old: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.

The missing msgfmt (from the gettext package which we will install later in this chapter) is not fatal. The files msgfmt would create are already pre-built, so you won't be missing out on anything. You would only need it if you make changes to the Glibc manual files. Since we don't do this by default, we can safely ignore it.

Command explanations

mknod -m 0666 /dev/null c 1 3: Glibc needs a null device to compile properly. All other devices will be created in the next section.

touch /etc/ld.so.conf One of the final steps of the Glibc installation is running ldconfig to update the dynamic loader cache. If this file doesn't exist, the installation will abort with an error that it can't read the file, so we simply create an empty file (the empty file will have Glibc default to using /lib and /usr/lib which is fine).

sed 's%\$(PERL)%/usr/bin/perl%' malloc/Makefile > tmp~: This sed command searches through malloc/Makefile and converts all occurrences of $(PERL) to /usr/bin/perl. The output is then written to the file tmp~. This is done because Glibc can't autodetect perl since it hasn't been installed yet.

mv tmp~ malloc/Makefile: The file tmp~ is now moved back to malloc/Makefile. We do this because when using sed, we can't write straight back to this file so we need to use a temporary file in between.

sed 's/root/0' login/Makefile > tmp~: This sed command replaces all occurences of root in login/Makefile with 0. This is because as we don't have glibc on the LFS system yet, usernames can't be resolved to their user id's. Therefore, we replace the username root with the id 0.

mv tmp~ login/Makefile: As above, we are using a temporary file (tmp~) to store the edited Makefile and then copying it back over the original.

--enable-add-ons: This enables the add-on that we install with Glibc: linuxthreads

--libexecdir=/usr/bin: This will cause the pt_chown program to be installed in the /usr/bin directory.

sed 's/cross-compiling = yes/cross-compiling = no/' config.make > config.make~: This time, we're replacing cross-compiling = yes with cross-compiling = no. We do this because we are only building for our own system. Cross-compiling is used, for instance, to build a package for an Apple Power PC on an Intel system. The reason Glibc thinks we're cross-compiling is that it can't compile a test program to determine this, so it automatically defaults to a cross-compiler. The reason for the failed program is because Glibc hasn't been installed yet.

mv config.make~ config.make: Again, we are moving the temporary file over the original.

exec /bin/bash:This command will start a new bash shell which will replace the current shell. This is done to get rid of the "I have no name!" message in the command prompt, which was caused by bash's inability to resolve a userid to a username (which in turn was caused by the missing Glibc installation).

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 doesn't need to create his own functions for every single task. The most common things like writing a string to the screen are already present and at the disposal of the programmer.

The C library (actually almost every library) come in two flavors: 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. The documentation that comes with the C Library describes this in more detail, as it is too complicated to explain here in one or two lines.

Dependencies

Glibc-2.2.4 needs the following to be installed:


sh from the bash package

ar from the binutils package
as from the binutils package
ld from the binutils package
ranlib from the binutils  package

cmp from the diffutils package

chmod from the fileutils package
cp from the fileutils package
ln from the fileutils package
mknod from the fileutils package
mv from the fileutils package
mkdir from the fileutils package
rm from the fileutils package
touch from the fileutils package

cpp from the gcc package
gcc from the gcc package

egrep from the grep package
grep from the grep package

gzip from the gzip package

make from the make package

mawk from the mawk package

sed from the sed package

basename from the sh-utils package
expr from the sh-utils package
pwd from the sh-utils package
uname from the sh-utils package

cat from the textutils package
sort from the textutils package
tr from the textutils package