Next Previous Contents

4. Installing as a test library.

This section covers installing glibc 2 as a test library. Anything you compile will be linked to your existing libraries unless you give some extra parameters to link to the new libraries. It appears that the paths are compiled into quite a few files, so you probably have to install the library from source.

4.1 Compiling and installing.

Prerequisites.

On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile with full libraries with add-ons. On a loaded i686@200, it takes about half an hour.

Extracting the source.

You need to extract the source from the archives so you can compile it. The best way to do this is:

 tar xzf glibc-2.0.6.tar.gz
 cd glibc-2.0.6
 tar xzf ../glibc-linuxthreads-2.0.6.tar.gz
 tar xzf ../glibc-crypt-2.0.6.tar.gz
 tar xzf ../glibc-localedata-2.0.6.tar.gz
 
This will put linuxthreads, crypt, and localedata directories in the glibc-2.0.6 directory where configure can find these add-ons.

Configuring.

In the glibc-2.0.6 directory, create a directory named compile, and cd into it. All work will be done in this directory, which will simplify cleaning up. (The developers have not been very concerned with getting 'make clean' perfect yet.)

 mkdir compile
 cd compile
 
Run ../configure. To use the add-on packages, you need to specify them with --enable-add-ons, such as --enable-add-ons=linuxthreads,crypt,localedata. You also need to choose a destination directory to install to. /usr/i486-linuxglibc2 is a good choice. The configure line for this would be:
 ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr/i486-linuxglibc2
 

Compiling and installing.

To compile and verify, run:

 make
 make check
 
If the 'make check' succeeds, install the library as root (while still in the compile/ directory):
 make install
 

4.2 Updating the dynamic loader.

  1. Create a link from the new ld.so to /lib/ld-linux.so.2:
     ln -s /usr/i486-linuxglibc2/lib/ld-linux.so.2 /lib/ld-linux.so.2
     
    
    This is the only library where the location is fixed once a program is linked, and using a link in /lib will ease upgrading to glibc as your primary C library when the stable version is released.
  2. Edit /etc/ld.so.conf. You need to add path to the lib directory the new libraries reside in at the end of the file, which will be <prefix>/lib, such as /usr/i486-linuxglibc2/lib for the choice above. After you have modified /etc/ld.so.conf, run
     ldconfig -v
     
    

4.3 Configuring for gcc.

The last step of installation is updating /usr/lib/gcc-lib so gcc knows how to use the new libraries. First you need to duplicate the existing configuration. To find out which configuration is current, use the -v option of gcc:

 % gcc -v
 Reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
 gcc version 2.7.2.2
 
In this case, i486-unknown-linux is the system, and 2.7.2.2 is the version. You need to copy the /usr/lib/gcc-lib/<system> to the new test system directory:
 cd /usr/lib/gcc-lib/
 cp -r i486-unknown-linux i486-linuxglibc2
 
Change into your new test system directory and version directory
 cd /usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2
 
and edit the file specs found in this directory. In this file, change /lib/ld-linux.so.1 to /lib/ld-linux.so.2. You also need to remove all expressions %{...:-lgmon} in the file, since glibc does not use the gmon library for profiling. A sample specs file can be found in the Sample specs file section.

4.4 Updating header file links.

You need create links in your new include directory to other include directories:

 cd /usr/i486-linuxglibc2/include
 ln -s /usr/src/linux/include/linux
 ln -s /usr/src/linux/include/asm
 ln -s /usr/X11R6/include/X11
 
You might also have other libraries such as ncurses which need their header files put in this directory. You should copy or link the files from /usr/include. (Some libraries may need to be recompiled with glibc2 in order to work with it. In these cases, just compile and install the package to /usr/i486-linuxglibc2.)

4.5 Testing your installation.

To test the installation, create the following program in a file glibc.c:

 #include <stdio.h>

 main()
 {
     printf("hello world!\n");
 }
 
and compile with the options of "-b <base install directory> -nostdinc -I<install directory>/include -I/usr/lib/gcc-lib/<new system dir>/<gcc version>/include":
 % gcc -b i486-linuxglibc2 -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include glibc.c -o glibc
 
Use ldd to verify the program was linked with glibc2, and not your old libc:
 % ldd glibc
 libc.so.6 => /usr/i486-linuxglibc2/lib/libc-2.0.6.so (0x4000d000)
 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
 
If it compiles, the links check out, and it generates "hello world!" when run, the installation succeeded.


Next Previous Contents

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:57:44