6.7. Installing Glibc-2.2.5

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

6.7.1. Installation of Glibc

Before starting to install glibc, you must cd into the glibc-2.2.5 directory and unpack glibc-linuxthreads inside the glibc-2.2.5 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. Also, don't pass the --enable-kernel option to the configure script. It's known to cause segmentation faults when other packages like fileutils, make and tar are linked against it.

Basically, compiling Glibc in any other way than the book suggests is putting your system at very high risk.

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.backup > malloc/Makefile &&
cp login/Makefile login/Makefile.backup &&
sed 's/root/0/' login/Makefile.backup > login/Makefile &&
mkdir ../glibc-build &&
cd ../glibc-build &&
../glibc-2.2.5/configure --prefix=/usr \
   --enable-add-ons --libexecdir=/usr/bin &&
echo "cross-compiling = no" > configparms &&
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.5 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) won't cause any problems. msgfmt is used to generate the binary translation files that are used to make your system talk in a different language. Because these translation files have already been generated for you, there is no need for msgfmt. You'd only need msgfmt if you change the translation source files (the *.po files in the po subdirectory) which\ would require you to re-generate the binary files.

6.7.2. 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.backup > malloc/Makefile: This sed command searches through malloc/Makefile.backup and converts all occurrences of $(PERL) to /usr/bin/perl. The output is then written to the original malloc/Makefile.in which is used during configuration. This is done because Glibc can't autodetect perl since it hasn't been installed yet.

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

--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.

echo "cross-compiling = no" > configparms: 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. Compiling the test program fails because Glibc hasn't been installed yet.

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).

6.7.3. Contents of glibc-2.2.5

6.7.3.2. Descriptions

6.7.3.4. Descriptions

6.7.4. Dependencies

Glibc-2.2.5 needs the following to be installed:


bash: sh
binutils: ar, as, ld, ranlib, readelf
diffutils: cmp
fileutils: chmod, cp, install, ln, mknod, mv, mkdir, rm, touch
gcc: cc, cc1, collect2, cpp, gcc
grep: egrep, grep
gzip: gzip
make: make
gawk: gawk
sed: sed
sh-utils: date, expr, hostname, pwd, uname
texinfo: install-info, makeinfo
textutils: cat, cut, sort, tr