Glibc Install HOWTO
Glibc Install HOWTO
Kai Schlachter
<linux (at) murphyslantech.de>
20040319
Revised by: KC
Table of Contents
Chapter 1. Preface..............................................................................................................................................1 1.1. Copyright..........................................................................................................................................1 1.2. Revision History...............................................................................................................................1 1.3. Thanks...............................................................................................................................................1 Chapter 2. Introduction ......................................................................................................................................2 2.1. Why?.................................................................................................................................................2 2.2. What?................................................................................................................................................2 Chapter 3. Preparations.....................................................................................................................................3 3.1. Stuff you will need............................................................................................................................3 3.1.1. Software you will need............................................................................................................3 3.1.2. Sources you will need ..............................................................................................................3 3.2. Special things you need to do...........................................................................................................3 3.2.1. Things you will definitely need...............................................................................................4 3.2.2. Software that may come in handy...........................................................................................7 Chapter 4. The installation of glibc itself..........................................................................................................8 4.1. Obtaining and compiling the source.................................................................................................8 4.2. The installation.................................................................................................................................8 4.2.1. LILO........................................................................................................................................9 4.2.2. Grub.........................................................................................................................................9 4.3. After the kernel is booted... ...............................................................................................................9 Chapter 5. Troubleshootingif something goes wrong... ...............................................................................11 5.1. Errors with configure or make while trying to compile glibc .........................................................11 5.2. Something goes wrong during make install....................................................................................11 5.2.1. Going back to a working configuration .................................................................................12
Chapter 1. Preface
1.1. Copyright
Copyright (c) 2004 by Kai Schlachter 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 FrontCover Texts, and no BackCover Texts. A copy of the license is located at http://www.gnu.org/licenses/fdl.html.
1.3. Thanks
I especially want to thank Nico Schmoigl for helping me get my crashed system back up after I ran make install for glibc while my system was still fully running. This was the main reason I wrote this miniHOWTO. 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.
Chapter 1. Preface
Chapter 2. Introduction
In this HOWTO I will explain how you install a new version of glibc on your system. I wrote this manual because I want to save others from the problems I encountered. 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. If you have any suggestions, found another bug in some distribution and how to fix it, please let me know by writing me an email: <linux_at_murphyslantech.de>.
2.1. Why?
Yes, that's a good question. Why would you need to install a new glibc? Well, there are several reasons: you are a developer and you need the new functions of the library you wanted to compile a new program that needs the new library you like the thrill of errors and bugs in new versions ;)
2.2. What?
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. 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 squareroot of a number, such common functions are stored in separate filesthe socalled 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. 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. I know this is not technically correct in all detail, but it gives you a basic understanding of the architecture behind.
Chapter 2. Introduction
Chapter 3. Preparations
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.)
Chapter 3. Preparations
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 nativelanguage support by using:
./configure nonls
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 make3.80.tar.bz2
8. Make a check:
make v
Chapter 3. Preparations
Glibc Installation HOWTO 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 staticlinked program. 3.2.1.3. the GNU coreutils The coreutils 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 coreutils5.0.tar.bz2
. 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 uptodate. 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/lfspackages/4.1/tar1.13.patch. 3. Unpack the source by invoking:
tar xzvf tar1.13.tar.gz
8. Compile with:
make
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 nativelanguage support (nls). You may achieve this by invoking configure with the option:
disablenls
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
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 bash2.05b.tar.gz
which will create a directory called bash2.05b with all the unpacked sources in it. 3. Go to the directory:
cd bash2.05a
This will install the binaries to /usr/local/bin/. 8. Make sure there is not another version laying around (like in my SuseLinux: /bin/), by copying the file:
cp /usr/local/bin/bash /bin/
We don't use a symlink here because both at boottime 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 staticallylinked 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.
5. Start compiling:
make
6. Install everything:
make install
Chapter 3. Preparations
3. In addition, you will need a package called "linuxthreads," found in the linuxthreads directory on ftp.gnu.org. The file is called:
glibclinuxthreads2.2.4.tar.gz
Make sure you get the version that corresponds to your glibc source tree. 4. Copy the linuxthreads package to your glibc source directory:
cp glibclinuxthreads2.2.4.tar.gz glibc2.2.4
6. Unpack linuxthreads:
tar xzvf linuxthreads2.2.4.tar.gz
This will configure the package in such a way that the linuxthreads are included in the compile; this is necessary for compliance with other Linux systems. For example, programs you compile will probably not run on another machine if you forget to include this package. 8. Afterwards, start the compilation of glibc:
make
This may take some time (about half an hour on my Duron XP, running with 1.5 GHz). Now that the library is compiled, everything is ready for the installation, but things are not as easy this time.
Glibc Installation HOWTO to your kernel. Depending on your bootloader you may need to do different things. In the following I will explain this using the two most common bootloaders, LILO (LInuxLOader) and GNU grub, as examples.
4.2.1. LILO
To start the "onlybasics" system, reboot your computer and at the LILO prompt enter the kernel imagename you like to load and append
init=/bin/bash
to it before pressing Return. If you are planing to replace your glibc more often, it might be a good idea to add a separate configuration to your /etc/lilo.conf. For details, refer to the manpage of LILO.
4.2.2. Grub
Grub is a newer bootloader, with enhanced support for different operating systems and and file system types (eg. it supports booting from reiserfs partitions). If you would like to know more go to: http://www.gnu.org/software/grub/, where you will find all the stuff you need. If you already have Grub installed, you probably use the textbased frontend to select the kernel you prefer to boot. Grub has a nice featureinstead of returning to doing everything by hand, you can simply select your entry and type e, which will bring up an option menu. In this menu you will see the commands Grub executes prior to booting the kernel. Simply select the line saying
kernel="/where/yourkernelis andoptionsare"
and press e again. Now you can edit this line. Here you just add
init=/bin/bash
and after pressing Return to make the changes take effect, press b to start booting.
At this moment your root (/) has been mounted as readonly, thus you will not be able to write the new library to your hard drive. To make it r/w, enter the command:
mount o remount,rw /
If your source is located on another partition you must also mount it, as it is not done for you (for me this means mounting my raid system): Chapter 4. The installation of glibc itself 9
As you see, I defined the file system type, which is needed because mount does not look anything up in /etc/fstab. Now you can go to the directory containing the source and type in:
make install
If you like, now might be a good time to pray that everything works out fine... ;) If everything went through properly, you will return to your prompt after the installation without any error message. In all other cases, please see Chapter 5. If everything goes fine, run:
ldconfig v
to update your library cache. Congratulations! The library is successfully installed. Now type in: mount o remount,ro / to ensure that all the data is written to the hard drive. Now start the reboot:
exit
This will cause an error message saying that you have caused a kernelpanic. If possible, restart the computer by using CTRLALTDEL, otherwise use your hardware's reset switch. Try booting your normal kernel. If everything turns out fine, you are ready to use the new library.
10
11
Glibc Installation HOWTO The only tool not static is mount and, for good reason in my opinion, it is included in the package of linuxutils, which also contains login, passwd, etc. Since you are not able to use staticallylinked versions in combination with PAM or other securityrelated software, it would be unwise to compile them statically under all circumstances. Of course you are free to do so if you are really sure about what you are doing.
12