Special things you need to do

Glibc Installation HOWTO
Prev | Chapter 3. Preparations | Next

# 3.2. Special things you need to do

Since you are going to substitute the basic library many programs rely on, you can imagine the problems that may occur.

For me, it so happened that everything went fine until I typed in make install. At about halfway through the installation process I got an error telling me that rm was not able to run, and I found out that even all the common commands like cp, ls, mv, ln, tar, etc., did not work; all told me that they were not able to find parts of the library they needed.

But there is help available. You can force the compilation of programs with the libraries compiled into them, so the programs do not need to look them up from the library.

For that reason, in this chapter, we will compile all the utilities we need for the install into a static version.

## 3.2.1. Things you will definitely need

### 3.2.1.1. The GNU-Binutils

1. Get the newest version from: ftp.gnu.org/gnu/binutils; at the time of writing, this was version 2.14

2. Open the package:

       tar xIvf binutils-2.14.tar.bz2

3. Change to the directory:

       cd binutils-2.14

4. Configure the Makefiles:

       ./configure

5. Compile the sources:

       make

6. Install them with:

       make install

If you run into trouble with the compilation of the binutils, referring to problems with gettext (indicated by errors like: "undeclared reference to lib_intl" or similar) please install the newest version, available from ftp.gnu.org/gnu/gettext.

If this does not help, try disabling the native-language support by using:

    ./configure --no-nls

You don't need to build a static version of the binutils, though it would not hurt, but I encountered many systems running with very old versions and ran into errors almost every time, so I think it is a good idea to mention them here.

### 3.2.1.2. GNU make

The make command is responsible for the compiling of the sources, calling gcc and all the other programs needed for a compile. Since you may need to compile something if a problem occurs with the new glibc, it is a good idea to have it static, otherwise it might not work after an error appears.

1. Download the source from ftp.gnu.org/gnu/make/; at the time of writing the current version was 3.80

2. Unpack the source, eg.:

       tar xIvf make-3.80.tar.bz2

3. Change to the created directory:

       cd make-3.80

4. Take care that the binaries are built static:

       export CFLAGS="-static -O2 -g"

5. Run the configure script:

       ./configure

6. Compile the stuff:

       make

7. Install the binaries:

       make install

8. Make a check:

       make -v

   You should now see the new version installed. If not, check for older binary files and replace them by smlinks to the new version.

Congratulations! You have compiled another static-linked program.

### 3.2.1.3. the GNU core-utils

The core-utils are commands like: cp, rm, ln, mv, etc. In case of an error in the installation, these are an absolute requirement to help bring your system up again, so static binaries are really necessary here.

1. Again, download the source tarball from: ftp.gnu.org/gnu/coreutils/; at the time of writing, version 5.0 was current.

2. Unpack it:

       tar xIvf coreutils-5.0.tar.bz2

3. Change to the directory:

       cd coreutils-5.0

4. Take care that the binaries are built static:

       export CFLAGS="-static -O2 -g"

5. Configure the package:

       ./configure

6. Compile the binaries:

       make

7. And install them:

       make install

8. Verify that the right core-utils are used:

       cp --version

   . You should see the correct version, otherwise remove any old binaries and replace them with symlinks to the new version.

Now that the binaries of these very elementary tools are static, you can be sure they will work every time you need them.

### 3.2.1.4. GNU tar

You have already used GNU tar to unpack all the programs compiled and installed so far. But maybe you need to compile another program which is needed by glibc after you had a crash, and in this situation (I experienced this myself!) it is very useful to have a working tar ready to unpack the missing programs. With tar, we also need to take care of the bz2 compression algorithm, which is not included in the normal source distribution of tar.

1. Get the source of GNU tar from ftp.gnu.org/gnu/tar; at the time of writing, version 1.13 was up-to-date.

2. As many source tarballs are compressed with bzip2, we would like to have the support built in, rather than working with pipes, so get the patch from: ftp://infogroep.be/pub/linux/lfs/lfs-packages/4.1/tar-1.13.patch.

3. Unpack the source by invoking:

       tar xzvf tar-1.13.tar.gz

4. Copy the patch to the source directory of tar:

       cp tar-1.13.patch tar-1.13/

5. Apply the patch:

       patch -Np1 -i tar-1.13.patch

6. Set the compiler flags to make a static binary:

       export CFLAGS="-static -O2 -g"

7. Now we are ready to configure:

       ./configure

8. Compile with:

       make

9. And as the next step, install the package:

       make install

10. Do a quick check to ensure the new version is being used from now on:

        tar --version

    The version you just installed should display, otherwise check for old binaries and replace them with symlinks to the new location.

If you experience problems with the execution of make, try to turn off native-language support (nls). You may achieve this by invoking configure with the option:

    --disable-nls

Note: In this new version of tar, you must use the `-j` switch to decompress .bzip2 files, so instead of

    tar xIvf anyfile.tar.bz2

you now have to use

    tar xjvf anyfile.tar.bz2

I do not know why this was changed, but it works fine.

### 3.2.1.5. The Bash shell

I prefer Bash as my shell; if you use a different one, please be sure you have installed a static version of it before you install glibc.

1. Get Bash from: ftp.gnu.org/gnu/bash/. Download the newest version you can find; at the time of writing this was version 2.05b.

2. Unpack the source tree:

       tar xzvf bash-2.05b.tar.gz

   which will create a directory called `bash-2.05b` with all the unpacked sources in it.

3. Go to the directory:

       cd bash-2.05a

4. Set everything up for building a static version:

       export CFLAGS="-static -O2 -g"

5. Configure the makefiles:

       ./configure

   If you would like something special in your Bash, see

       ./configure --help

   for a list of options.

6. Compile everything:

       make

7. Install the compiled binaries:

       make install

   This will install the binaries to `/usr/local/bin/`.

8. Make sure there is not another version laying around (like in my Suse-Linux: `/bin/`), by copying the file:

       cp /usr/local/bin/bash /bin/

   We don't use a symlink here because both at boot-time and when starting Bash there might be trouble with symlinks.

You now have installed a static version of Bash. For that reason, the binary is much bigger than usual, but it will run under all circumstances.

If you prefer to use another shell, you are free to do so, but make sure it is a statically-linked version. Feel free to email me a method to build the shell of your choice in a static version, and chances are good that it will be implemented in the next revision of this document.

## 3.2.2. Software that may come in handy

### 3.2.2.1. Midnight Commander

Midnight Commander is a very useful file manager, supporting many nice features like transparent decompression of packed files, built-in copy, move and other common commands, as well as an integrated editor.

To compile this piece of software, you will need to have glib installed; in some distributions this is already the case. If you get an error in the make command saying that ld could not find glib, you will need to install this library first. You can get the sources from: ftp.gnome.org/pub/gnome/sources/glib/2.2/, and the installation is straight-forward.

Here are the steps to build Midnight Commander:

1. Get the source from http://www.ibiblio.org/pub/Linux/utils/file/managers/mc/"; at the time of writing, the newest version was 4.6.0.

2. Unpack the sources:

       tar xzvf mc-4.6.0.tar.gz

3. Change to the directory you just created:

       cd mc-4.6.0

4. Set up the configuration-files:

       ./configure

5. Start compiling:

       make

6. Install everything:

       make install

Prev | Home | Next
Stuff you will need | Up | The installation of glibc itself