Installing Glibc-2.2.5

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.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) 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 internationalization (i18n) 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.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).

Contents of glibc-2.2.5

Program Files

catchsegv, gencat, getconf, getent, glibcbug, iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale, localedef, mtrace, nscd, nscd_nischeck, pcprofiledump, pt_chown, rpcgen, rpcinfo, sln, sprof, tzselect, xtrace, zdump and zic

Descriptions

catchsegv

No description is currently available.

gencat

gencat generates message catalogues.

getconf

No description is currently available.

getent

getent gets entries from an administrative database.

glibcbug

glibcbug creates a bug report about glibc and and mails it to the bug email address.

iconv

iconv performs character set conversion.

iconvconfig

iconvconfig creates fastloading iconv module configuration file.

ldconfig

ldconfig configures the dynamic linker run time bindings.

ldd

ldd prints the shared libraries required by each program or shared library specified on the command line.

lddlibc4

No description is currently available.

locale

No description is currently available.

localedef

localedef compiles locale specifications.

mtrace

No description is currently available.

nscd

nscd is a daemon that provides a cache for the most common name service requests.

nscd_nischeck

No description is currently available.

pcprofiledump

pcprofiledump dumps information generated by PC profiling.

pt_chown

pt_chown sets the owner, group and access permission of the slave pseudo terminal corresponding to the master pseudo terminal passed on file descriptor `3'. This is the helper program for the `grantpt' function. It is not intended to be run directly from the command line.

rpcgen

No description is currently available.

rpcinfo

No description is currently available.

sln

sln symbolically links dest to source. It is statically linked, needing no dynamic linking at all. Thus sln is useful to make symbolic links to dynamic libraries if the dynamic linking system for some reason is nonfunctional.

sprof

sprof reads and displays shared object profiling data.

tzselect

tzselect asks the user for information about the current location and outputs the resulting time zone description to standard output.

xtrace

xtrace traces execution of program by printing the currently executed function.

zdump

zdump is the time zone dumper.

zic

zic is the time zone compiler.

Library Files

ld.so, libBrokenLocale.[a,so], libBrokenLocale_p.a, libSegFault.so, libanl.[a,so], libanl_p.a, libbsd-compat.a, libc.[a,so], libc_nonshared.a, libc_p.a, libcrypt.[a,so], libcrypt_p.a, libdl.[a,so], libdl_p.a, libg.a, libieee.a, libm.[a,so], libm_p.a, libmcheck.a, libmemusage.so, libnsl.a, libnsl_p.a, libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so, libnss_nis.so, libnss_nisplus.so, libpcprofile.so, libpthread.[a,so], libpthread_p.a, libresolv.[a,so], libresolv_p.a, librpcsvc.a, librpcsvc_p.a, librt.[a,so], librt_p.a, libthread_db.so, libutil.[a,so] and libutil_p.a

Descriptions

ld.so

ld.so is the helper program for shared library executables.

libBrokenLocale, libBrokenLocale_p

No description is currently available.

libSegFault

No description is currently available.

libanl, libanl_p

No description is currently available.

libbsd-compat

No description is currently available.

libc, libc_nonshared, libc_p

These files constitute the main C library. 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.

libcrypt, libcrypt_p

libcrypt is the cryptography library.

libdl, libdl_p

No description is currently available.

libg

No description is currently available.

libieee

No description is currently available.

libm, libm_p

libm is the mathematical library.

libmcheck

No description is currently available.

libmemusage

No description is currently available.

libnsl, libnsl_p

No description is currently available.

libpcprofile

No description is currently available.

libpthread, libpthread_p

No description is currently available.

libresolv, libresolv_p

No description is currently available.

librpcsvc, librpcsvc_p

No description is currently available.

librt, librt_p

No description is currently available.

libthread_db

No description is currently available.

libutil, libutil

No description is currently available.

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
mawk: mawk
sed: sed
sh-utils: date, expr, hostname, pwd, uname
texinfo: install-info, makeinfo
textutils: cat, cut, sort, tr