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.
Get the newest version from: ftp.gnu.org/gnu/binutils; at the time of writing, this was version 2.14
Open the package:
tar xIvf binutils-2.14.tar.bz2
Change to the directory:
cd binutils-2.14
Configure the Makefiles:
./configure
Compile the sources:
make
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.
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.
Download the source from ftp.gnu.org/gnu/make/; at the time of writing the current version was 3.80
Unpack the source, eg.:
tar xIvf make-3.80.tar.bz2
Change to the created directory:
cd make-3.80
Take care that the binaries are built static:
export CFLAGS="-static -O2 -g"
Run the configure script:
./configure
Compile the stuff:
make
Install the binaries:
make install
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.
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.
Again, download the source tarball from: ftp.gnu.org/gnu/coreutils/; at the time of writing, version 5.0 was current.
Unpack it:
tar xIvf coreutils-5.0.tar.bz2
Change to the directory:
cd coreutils-5.0
Take care that the binaries are built static:
export CFLAGS="-static -O2 -g"
Configure the package:
./configure
Compile the binaries:
make
And install them:
make install
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.
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.
Get the source of GNU tar from ftp.gnu.org/gnu/tar; at the time of writing, version 1.13 was up-to-date.
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.
Unpack the source by invoking:
tar xzvf tar-1.13.tar.gz
Copy the patch to the source directory of tar:
cp tar-1.13.patch tar-1.13/
Apply the patch:
patch -Np1 -i tar-1.13.patch
Set the compiler flags to make a static binary:
export CFLAGS="-static -O2 -g"
Now we are ready to configure:
./configure
Compile with:
make
And as the next step, install the package:
make install
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.
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.
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.
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.
Go to the directory:
cd bash-2.05a
Set everything up for building a static version:
export CFLAGS="-static -O2 -g"
Configure the makefiles:
./configure
If you would like something special in your Bash, see
./configure --help
for a list of options.
Compile everything:
make
Install the compiled binaries:
make install
This will install the binaries to /usr/local/bin/
.
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.
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:
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.
Unpack the sources:
tar xzvf mc-4.6.0.tar.gz
Change to the directory you just created:
cd mc-4.6.0
Set up the configuration-files:
./configure
Start compiling:
make
Install everything:
make install