<revremark>Initial Release, reviewed by LDP</revremark>
</revision>
</revhistory>
</bookinfo>
<chapterid="preface">
<title>Preface</title>
<sect1id="copyright">
<title>Copyright</title>
<para>Copyright (c) 2004 by Kai Schlachter</para>
<para>Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is located at <ulinkurl="http://www.gnu.org/licenses/fdl.html"/>.</para>
</sect1>
<sect1id="history">
<title>Revision History</title>
<para>
<itemizedlist>
<listitem><para>v1.01: Fixed some missplaced quotation marks</para></listitem>
</itemizedlist>
</para>
</sect1>
<sect1id="thanks">
<title>Thanks</title>
<para>I especially want to thank Nico Schmoigl for helping me get
my crashed system back up after I ran <command>make install</command> for
glibc while my system was still fully running. This was the main reason I wrote this mini-HOWTO.
</para>
<para>Thanks also go to all the other people who helped me along the way; getting the HOWTO in correct format, finding all the typos, etc.</para>
</sect1>
</chapter>
<chapterid="introduction">
<title>Introduction</title>
<para>In this HOWTO I will explain how you install a new version
of <productname>glibc</productname> on your system.</para>
<para>I wrote this manual because I want to save others from the
problems I encountered.</para>
<para>This HOWTO is a kind of guideline, made up from settings and ways of
doing things that worked out for me. No liability for the contents of this document can be accepted. Use the concepts, examples and other content at your own risk. You are strongly recommended to make a backup of your system before major installations and backups at regular intervals.</para>
<para>If you have any suggestions, found another bug in some
distribution and how to fix it, please let me know by writing me
an e-mail: <email>linux_at_murphyslantech.de</email>.</para>
<sect1id="why">
<title>Why?</title>
<para>
Yes, that's a good question. Why would you need to install a new
glibc? Well, there are several reasons:
<itemizedlist>
<listitem><para>you are a developer and you need the new functions of the library</para></listitem>
<listitem><para>you wanted to compile a new program that needs the new library</para></listitem>
<listitem><para>you like the thrill of errors and bugs in new versions ;-)</para></listitem>
</itemizedlist>
</para>
</sect1>
<sect1id="what">
<title>What?</title>
<para>
If you do not know what glibc is by now, don't worry! When I
first had problems with a new program I wanted to compile, I only
knew that my version of glibc was not sufficient for the
compile. Now that I know more, I will try to explain in a very simple way what
glibc does.</para>
<para>The glibc package contains a library written in the
programming language of C. Libraries are a very useful thing in programming;
instead of inventing the wheel from scratch for operations such as
computing the square-root of a number, such common functions
are stored in separate files—the so-called libraries.
When a new version of a library is published it often contains
some new functions, uses more efficient algorithms for already
implemented functions, and so on.</para>
<para>This is the reason why some programs complain about an older
version of glibc: the current version just does not contain all the functions
the program needs in order to run.</para>
<para>I know this is not technically correct in all detail, but it
gives you a basic understanding of the architecture behind.</para>
</sect1>
</chapter>
<chapterid="preparations">
<title>Preparations</title>
<para>
As an installation of glibc is not an easy task. You need to do a lot of things in advance, especially in the event that something goes
wrong. (That is what happened to me on my first glibc install, and I did not make any preparations.)</para>
<!-- Pehaps write a certain todo-list about what we are going to do ... -->
<sect1id="stuff-you-will-need">
<title>Stuff you will need</title>
<para>Basically, you need two different things: software that is already running on your machine (eg., pre-installed by your distribution) and packages
<command>ln</command>, <command>tar</command>, etc., did not work; all told me
that they were not able to find parts of the library they needed.</para>
<para>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.</para>
<para>For that reason, in this chapter, we will compile all the
utilities we need for the install into a static version.</para>
<sect2id="things-you-will-definitely-need">
<title>Things you will definitely need</title>
<sect3id="the-gnu-binutils">
<title>The GNU-Binutils</title>
<para>
<orderedlist>
<listitem><para>Get the newest version from: <ulinkurl="ftp.gnu.org/gnu/binutils">ftp.gnu.org/gnu/binutils</ulink>; at the time of writing, this was version 2.14</para></listitem>
<listitem><para>Open the package: <screen>tar xIvf binutils-2.14.tar.bz2</screen></para></listitem>
<listitem><para>Change to the directory: <screen>cd binutils-2.14</screen></para></listitem>
<listitem><para>Configure the Makefiles: <screen>./configure</screen></para></listitem>
<listitem><para>Compile the sources: <screen>make</screen></para></listitem>
<listitem><para>Install them with: <screen>make install</screen></para></listitem>
</orderedlist>
</para>
<para>
If you run into trouble with the compilation of the binutils,
referring to problems with gettext (indicated by errors like:
<quote>undeclared reference to lib_intl</quote> or similar) please install the
newest version, available from <ulinkurl="ftp.gnu.org/gnu/gettext">ftp.gnu.org/gnu/gettext</ulink>.</para>
<para>If this does not help, try disabling the native-language support by using: <screen>./configure --no-nls</screen></para>
<para>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.</para>
</sect3>
<sect3id="gnu-make">
<title>GNU make</title>
<para>The <command>make</command> 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.</para>
<para>
<orderedlist>
<listitem><para>Download the source from <ulinkurl="ftp.gnu.org/gnu/make/">ftp.gnu.org/gnu/make/</ulink>; at the time of writing the current version was 3.80</para></listitem>
<listitem><para>Unpack the source, eg.: <screen>tar xIvf make-3.80.tar.bz2</screen></para></listitem>
<listitem><para>Change to the created directory: <screen>cd make-3.80</screen></para></listitem>
<listitem><para>Take care that the binaries are built static: <screen>export CFLAGS="-static -O2 -g"</screen></para></listitem>
<listitem><para>Run the configure script: <screen>./configure</screen></para></listitem>
<listitem><para>Compile the stuff: <screen>make</screen></para></listitem>
<listitem><para>Install the binaries: <screen>make install</screen></para></listitem>
<listitem><para>Make a check:<screen>make -v</screen> You should now see the new version installed. If not, check for older binary files and replace them by smlinks to the new version.</para></listitem>
</orderedlist>
</para>
<para>
Congratulations! You have compiled another static-linked program.
</para>
</sect3>
<sect3id="gnu-core-utils">
<title>the GNU core-utils</title>
<para>The core-utils are commands like: <command>cp</command>, <command>rm</command>, <command>ln</command>, <command>mv</command>, 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.</para>
<para>
<orderedlist>
<listitem><para>Again, download the source tarball from: <ulinkurl="ftp.gnu.org/gnu/coreutils/">ftp.gnu.org/gnu/coreutils/</ulink>; at the time of writing, version 5.0 was current.</para></listitem>
<listitem><para>Verify that the right core-utils are used: <screen>cp --version</screen>. You should see the correct version, otherwise remove any old binaries and replace them with symlinks to the new version.</para></listitem>
</orderedlist>
</para>
<para>
Now that the binaries of these very elementary tools are static,
you can be sure they will work every time you need them.
</para>
</sect3>
<sect3id="gnu-tar">
<title>GNU tar</title>
<para>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 <command>tar</command> 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.</para>
<para>
<orderedlist>
<listitem><para>Get the source of GNU tar from <ulinkurl="ftp.gnu.org/gnu/tar">ftp.gnu.org/gnu/tar</ulink>; at the time of writing, version 1.13 was up-to-date.</para></listitem>
<listitem><para>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:
<listitem><para>And as the next step, install the package:<screen>make install</screen></para></listitem>
<listitem><para>Do a quick check to ensure the new version is being used from now on: <screen>tar --version</screen> The version you just installed should display, otherwise
check for old binaries and replace them with symlinks to the new location.</para></listitem>
</orderedlist></para>
<para>If you experience problems with the execution of <command>make</command>, try to turn
off native-language support (nls). You may achieve this by
invoking configure with the option: <screen>--disable-nls</screen></para>
<para><emphasis>Note:</emphasis> In this new version of tar, you must use the <option>-j</option> switch to
decompress .bzip2 files, so instead of <screen>tar xIvf anyfile.tar.bz2</screen> you now have to use <screen>tar xjvf anyfile.tar.bz2</screen> I
do not know why this was changed, but it works fine.</para>
</sect3>
<sect3id="the-bash">
<title>The Bash shell</title>
<para>
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.</para>
<para>
<orderedlist>
<listitem><para>Get Bash from: <ulinkurl="ftp.gnu.org/gnu/bash/">ftp.gnu.org/gnu/bash/</ulink>. Download the newest
version you can find; at the time of writing this was version 2.05b.</para></listitem>
<listitem><para>Unpack the source tree: <screen>tar xzvf bash-2.05b.tar.gz</screen> which
will create a directory called <filename>bash-2.05b</filename> with all the unpacked sources in it.</para></listitem>
<listitem><para>Go to the directory: <screen>cd bash-2.05a</screen></para></listitem>
<listitem><para>Set everything up for building a static version: <screen>export CFLAGS="-static -O2 -g"</screen></para></listitem>
<listitem><para>Configure the makefiles: <screen>./configure</screen> If you would like something special in your Bash, see <screen>./configure --help</screen>
<listitem><para>Install the compiled binaries: <screen>make install</screen> This will install the binaries to <filename>/usr/local/bin/</filename>.</para></listitem>
<listitem><para>Make sure there is not another version laying around (like in my Suse-Linux: <filename>/bin/</filename>), by copying the file:
<screen>cp /usr/local/bin/bash /bin/</screen> We don't use a symlink here because both at boot-time and when starting Bash there might be trouble with symlinks.
</para></listitem>
</orderedlist>
</para>
<para>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.</para>
<para>
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.
</para>
</sect3>
</sect2>
<sect2id="software-that-may-come-in-handy">
<title>Software that may come in handy</title>
<sect3id="midnight-commander">
<title>Midnight Commander</title>
<para>
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.</para>
<para>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 <command>make</command> command saying that ld could not
find glib, you will need to install this library first. You can get the sources from:
<ulinkurl="ftp.gnome.org/pub/gnome/sources/glib/2.2/">ftp.gnome.org/pub/gnome/sources/glib/2.2/</ulink>, and the installation is straight-forward.</para>
<!-- maybe add a short section about the installation of glib -->
<para>Here are the steps to build Midnight Commander:</para>
<para>Now we come to the most important thing: the glibc install.</para>
<sect1id="obtaining-and-compiling-the-source">
<title>Obtaining and compiling the source</title>
<para>There are several versions of glibc available, but not in all cases are
new versions really better than the old ones. The best thing you
can do to find out which works and which ones you should not use is to
check out the different forums on the Internet. If you have
someone to ask, talk to him about the topic. Maybe he already has
installed the new version and might be able to tell you that version x.y.z is a
PITA, but version a.b.c works really well!</para>
<para>I decided to install glibc-2.2.4, as I was told it
works well, but it is your decision which one to choose.</para>
<para>Ok, now let's go to work:</para>
<para><orderedlist>
<listitem><para>Get the source from <ulinkurl="ftp.gnu.org/gnu/glibc/">ftp.gnu.org/gnu/glibc/</ulink>; as I said, I used version 2.2.4.</para></listitem>
<listitem><para>Unpack the source: <screen>tar -xzvf glibc-2.2.4.tar.gz</screen></para></listitem>
<listitem><para>In addition, you will need a package called
<quote>linuxthreads,</quote> found in the <filename>linuxthreads</filename>
directory on
<ulinkurl="ftp.gnu.org">ftp.gnu.org</ulink>. The file is called: <screen>glibc-linuxthreads-2.2.4.tar.gz</screen> Make sure you get the version that
corresponds to your glibc source tree.</para></listitem>
<listitem><para>Copy the linuxthreads package to your glibc source directory: <screen>cp glibc-linuxthreads-2.2.4.tar.gz glibc-2.2.4</screen></para></listitem>
<listitem><para>Change to the glibc directory: <screen>cd glibc-2.2.4</screen></para></listitem>