home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / GLIBC2-H < prev    next >
Text File  |  1999-11-04  |  35KB  |  1,321 lines

  1.   Glibc 2 HOWTO
  2.   Eric Green, ejg3@cornell.edu
  3.   v1.5, 8 February 1998
  4.  
  5.   The glibc 2 HOWTO covers installing and using the GNU C Library ver-
  6.   sion 2 (libc 6) on Linux systems.
  7.   ______________________________________________________________________
  8.  
  9.   Table of Contents
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   1. Introduction.
  68.  
  69.      1.1 About glibc 2.
  70.      1.2 About this document.
  71.      1.3 Recent changes in this document.
  72.  
  73.   2. Choosing your installation method.
  74.  
  75.   3. Getting the library.
  76.  
  77.   4. Installing as a test library.
  78.  
  79.      4.1 Compiling and installing.
  80.         4.1.1 Prerequisites.
  81.         4.1.2 Extracting the source.
  82.         4.1.3 Configuring.
  83.         4.1.4 Compiling and installing.
  84.      4.2 Updating the dynamic loader.
  85.      4.3 Configuring for gcc.
  86.      4.4 Updating header file links.
  87.      4.5 Testing your installation.
  88.  
  89.   5. Installing as the primary C library.
  90.  
  91.      5.1 Building the library from source.
  92.         5.1.1 Prerequisites.
  93.         5.1.2 Extracting the source.
  94.         5.1.3 Configuring.
  95.         5.1.4 Compiling.
  96.      5.2 Preparing for installation.
  97.      5.3 Installing from the binary package.
  98.      5.4 Installing from the source.
  99.      5.5 Updating the gcc specs.
  100.      5.6 Testing your installation.
  101.  
  102.   6. Compiling with the non-primary libc.
  103.  
  104.      6.1 A warning when using non-primary libcs.
  105.      6.2 Compiling programs with a test glibc.
  106.      6.3 Compiling programs with libc 5 when glibc is primary library.
  107.  
  108.   7. Compiling C++ programs.
  109.  
  110.      7.1 Installing libg++ for a test glibc install.
  111.      7.2 Installing libg++ for a primary glibc install.
  112.      7.3 Compiling C++ programs with the non-primary libc.
  113.  
  114.   8. Reporting bugs.
  115.  
  116.   9. Sample specs file.
  117.  
  118.   10. Miscellanea.
  119.  
  120.      10.1 Further information.
  121.         10.1.1 Web pages.
  122.         10.1.2 Newgroups.
  123.         10.1.3 Mailing lists.
  124.      10.2 Credits.
  125.      10.3 Feedback.
  126.      10.4 Copyright.
  127.  
  128.  
  129.   ______________________________________________________________________
  130.  
  131.  
  132.  
  133.   1.  Introduction.
  134.  
  135.  
  136.  
  137.   1.1.  About glibc 2.
  138.  
  139.  
  140.   Glibc 2 is the latest version of the GNU C Library. It currently runs
  141.   unmodified on GNU Hurd systems and Linux i386, m68k, and alpha
  142.   systems.  Support for Linux PowerPC, MIPS, Sparc, Sparc 64, and Arm
  143.   will be in version 2.1.  In the future support for other architectures
  144.   and operating systems will be added.
  145.  
  146.   On Linux, glibc 2 is used as the libc with major version 6, the
  147.   successor of the Linux libc 5.  It is intended by the Linux libc
  148.   developers to eventually replace libc 5.  As of 2.0.6, glibc is
  149.   considered production quality.  Version 2.1 (due out in the near
  150.   future) will be ready for main stream use along with adding more ports
  151.   and features.
  152.  
  153.   There are three optional add-ons available for glibc 2:
  154.  
  155.      Crypt
  156.         The UFC-crypt package.  It is seperate  because of export
  157.         restrictions.
  158.  
  159.      LinuxThreads
  160.         An implementation of the Posix 1003.1c "pthread" interface.
  161.  
  162.      Locale data
  163.         Contains the data needed to build the locale data files to use
  164.         the internationalization features of the glibc.
  165.  
  166.   The crypt and LinuxThreads add-ons are strongly recommended... not
  167.   using them risks to be incompatible with the libraries of other
  168.   systems.  (If you do not wish to use them, you must add the option
  169.   --disable-sanity-checks when you run configure.)
  170.  
  171.  
  172.   1.2.  About this document.
  173.  
  174.  
  175.   This HOWTO covers installing the glibc 2 library on an existing Linux
  176.   system.  It is tailored for users of Intel based systems currently
  177.   using libc 5, but users of other systems and alternate libraries (such
  178.   as glibc 1) should be able to use this information by substituting the
  179.   proper filenames and architecture names in the appropriate places.
  180.  
  181.   The latest copy of this HOWTO can be found as part of the Linux
  182.   Documentation Project <http://sunsite.unc.edu/LDP> or from
  183.   <http://www.imaxx.net/~thrytis/glibc/Glibc2-HOWTO.html>.
  184.  
  185.  
  186.   1.3.  Recent changes in this document.
  187.  
  188.  
  189.   Differences between version 1.5 and 1.4:
  190.  
  191.   o  Indexing added Ed Bailey.
  192.  
  193.   o  Changed my email address.
  194.  
  195.   Differences between version 1.4 and 1.3:
  196.  
  197.   o  Changed current status from experimental to production.
  198.  
  199.   o  Updated list of developmental ports.
  200.  
  201.   o  Updated latest version to 2.0.6.
  202.  
  203.  
  204.  
  205.   2.  Choosing your installation method.
  206.  
  207.  
  208.   There are a few ways to install glibc.  You can install the libraries
  209.   as a test, using the existing libraries as the default but letting you
  210.   try the new libraries by using different options when compiling your
  211.   program.  Installing in this way also makes it easy to remove glibc in
  212.   the future (though any program linked with glibc will no longer work
  213.   after the libraries are removed). Using glibc as a test library
  214.   requires you to compile the libraries from source.  There is no binary
  215.   distribution for installing libraries this way.  This installation is
  216.   described in ``Installing as a test library''.
  217.  
  218.   The other way described in this document to install is using glibc as
  219.   your primary library.  All new programs that you compile on your
  220.   system will use glibc, though you can link programs with your old
  221.   libraries using different options while compiling.  You can either
  222.   install the libraries from binaries, or compile the library yourself.
  223.   If you want to change optimization or configuration options, or use an
  224.   add-on which is not distributed as a binary package, you must get the
  225.   source distribution and compile.  This installation procedure is
  226.   described in ``Installing as the primary C library''.
  227.  
  228.   Frodo Looijaard describes yet another way of installing glibc.  His
  229.   method involves installing glibc as a secondary library and setting up
  230.   a cross compiler to compile using glibc.  The installation procedure
  231.   for this method is more complicated then the test library install
  232.   described in this document, but allows for easier compiling when
  233.   linking to glibc.  This method is described in his Installing glibc-2
  234.   on Linux <http://huizen.dds.nl/~frodol/glibc/> document.
  235.  
  236.   If you are currently running Debian 1.3 but do not want to upgrade to
  237.   the unstable version of Debian to use glibc, the Debian libc5 to libc6
  238.   Mini-HOWTO <http://www.gate.net/~storm/FAQ/libc5-libc6-Mini-
  239.   HOWTO.html> describes how to use Debian packages to upgrade your
  240.   system.
  241.  
  242.   If you are installing glibc 2 on an important system, you might want
  243.   to use the test install.  Even if there are no bugs, some programs
  244.   will need to be modified before they will compile due to changes in
  245.   function prototypes and types.
  246.  
  247.  
  248.  
  249.   3.  Getting the library.
  250.  
  251.  
  252.   The glibc 2 consists of the glibc package and three optional add-on
  253.   packages, LinuxThreads, Locale, and Crypt.  The source can be found at
  254.  
  255.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.6.tar.gz>
  256.  
  257.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-linuxthreads-2.0.6.tar.gz>
  258.  
  259.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-localedata-2.0.6.tar.gz>
  260.  
  261.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.6.tar.gz>
  262.  
  263.   It will take about 150 MB of disk space for the full compile and
  264.   install.  The basic binary install of just the core library package is
  265.   about 50 MB.
  266.  
  267.   Binary packages for 2.0.6 are not available.  Version 2.0.4 binary
  268.   packages are available for i386 and m68k, and version 2.0.1 for the
  269.   alpha can be found at
  270.  
  271.   o  Intel x86:
  272.  
  273.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.4.bin.i386.tar.gz>
  274.  
  275.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.4.bin.i386.tar.gz>
  276.  
  277.   o  Alpha:
  278.  
  279.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.1.bin.alpha-linux.tar.gz>
  280.  
  281.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.1.bin.alpha-
  282.      linux.tar.gz>
  283.  
  284.   o  m68k:
  285.  
  286.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.4-m68k-linux.bin.tar.gz>
  287.  
  288.   o  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.4-m68k-
  289.      linux.bin.tar.gz>
  290.  
  291.      There are export restrictions on the crypt add-on.  Non-US users
  292.      should get it from  <ftp://ftp.ifi.uio.no/pub/gnu>.
  293.  
  294.   If you are running a Red Hat distribution, you can get rpms for glibc
  295.   2 from <ftp://ftp.redhat.com/pub/redhat/>.  Glibc 2 is the primary C
  296.   library for the new Red Hat distribution 5.0.
  297.  
  298.   If you are running a Debian distribution, you can get the packages for
  299.   glibc 2 from  <ftp://ftp.debian.org/debian/dists/unstable/main/>.  The
  300.   files are named libc6.  Glibc 2 is now part of the base package of the
  301.   hamm version of Debian, and will be the primary libc when Debian 2.0
  302.   is released.
  303.  
  304.  
  305.  
  306.   4.  Installing as a test library.
  307.  
  308.  
  309.   This section covers installing glibc 2 as a test library.  Anything
  310.   you compile will be linked to your existing libraries unless you give
  311.   some extra parameters to link to the new libraries.  It appears that
  312.   the paths are compiled into quite a few files, so you probably have to
  313.   install the library from source.
  314.  
  315.  
  316.   4.1.  Compiling and installing.
  317.  
  318.  
  319.  
  320.   4.1.1.  Prerequisites.
  321.  
  322.  
  323.  
  324.   o  About 150 MB free disk space
  325.  
  326.   o  GNU make 3.75
  327.  
  328.   o  gcc >= 2.7.2 (better 2.7.2.1)
  329.  
  330.  
  331.   o  binutils 2.8.1 (for alpha you need a snapshot)
  332.  
  333.   o  bash 2.0
  334.  
  335.   o  autoconf 2.12 (if you change configure.in)
  336.  
  337.   o  texinfo 3.11
  338.  
  339.   On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile
  340.   with full libraries with add-ons.  On a loaded i686@200, it takes
  341.   about half an hour.
  342.  
  343.  
  344.   4.1.2.  Extracting the source.
  345.  
  346.  
  347.   You need to extract the source from the archives so you can compile
  348.   it.  The best way to do this is:
  349.  
  350.  
  351.         tar xzf glibc-2.0.6.tar.gz
  352.         cd glibc-2.0.6
  353.         tar xzf ../glibc-linuxthreads-2.0.6.tar.gz
  354.         tar xzf ../glibc-crypt-2.0.6.tar.gz
  355.         tar xzf ../glibc-localedata-2.0.6.tar.gz
  356.  
  357.  
  358.  
  359.  
  360.  
  361.   This will put linuxthreads, crypt, and localedata directories in the
  362.   glibc-2.0.6 directory where configure can find these add-ons.
  363.  
  364.  
  365.   4.1.3.  Configuring.
  366.  
  367.  
  368.   In the glibc-2.0.6 directory, create a directory named compile, and cd
  369.   into it.  All work will be done in this directory, which will simplify
  370.   cleaning up.  (The developers have not been very concerned with
  371.   getting 'make clean' perfect yet.)
  372.  
  373.  
  374.         mkdir compile
  375.         cd compile
  376.  
  377.  
  378.  
  379.  
  380.  
  381.   Run ../configure.  To use the add-on packages, you need to specify
  382.   them with --enable-add-ons, such as --enable-add-ons=linux-
  383.   threads,crypt,localedata.  You also need to choose a destination
  384.   directory to install to.  /usr/i486-linuxglibc2 is a good choice.  The
  385.   configure line for this would be:
  386.  
  387.  
  388.         ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr/i486-linuxglibc2
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.   4.1.4.  Compiling and installing.
  398.  
  399.  
  400.   To compile and verify, run:
  401.  
  402.  
  403.         make
  404.         make check
  405.  
  406.  
  407.  
  408.  
  409.  
  410.   If the 'make check' succeeds, install the library:
  411.  
  412.  
  413.         make install
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.   4.2.  Updating the dynamic loader.
  421.  
  422.  
  423.  
  424.   1. Create a link from the new ld.so to /lib/ld-linux.so.2:
  425.  
  426.  
  427.         ln -s /usr/i486-linuxglibc2/lib/ld-linux.so.2 /lib/ld-linux.so.2
  428.  
  429.  
  430.  
  431.  
  432.  
  433.   This is the only library where the location is fixed once a program is
  434.   linked, and using a link in /lib will ease upgrading to glibc as your
  435.   primary C library when the stable version is released.
  436.  
  437.   2. Edit /etc/ld.so.conf.  You need to add path to the lib directory
  438.      the new libraries reside in at the end of the file, which will be
  439.      <prefix>/lib, such as /usr/i486-linuxglibc2/lib for the choice
  440.      above.  After you have modified /etc/ld.so.conf, run
  441.  
  442.  
  443.         ldconfig -v
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.   4.3.  Configuring for gcc.
  451.  
  452.   The last step of installation is updating /usr/lib/gcc-lib so gcc
  453.   knows how to use the new libraries.  First you need to duplicate the
  454.   existing configuration.  To find out which configuration is current,
  455.   use the -v option of gcc:
  456.  
  457.  
  458.         % gcc -v
  459.         Reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
  460.         gcc version 2.7.2.2
  461.  
  462.  
  463.   In this case, i486-unknown-linux is the system, and 2.7.2.2 is the
  464.   version.  You need to copy the /usr/lib/gcc-lib/<system> to the new
  465.   test system directory:
  466.  
  467.  
  468.         cd /usr/lib/gcc-lib/
  469.         cp -r i486-unknown-linux i486-linuxglibc2
  470.  
  471.  
  472.  
  473.  
  474.  
  475.   Change into your new test system directory and version directory
  476.  
  477.  
  478.         cd /usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2
  479.  
  480.  
  481.  
  482.  
  483.  
  484.   and edit the file specs found in this directory.  In this file, change
  485.   /lib/ld-linux.so.1 to /lib/ld-linux.so.2.  You also need to remove all
  486.   expressions %{...:-lgmon} in the file, since glibc does not use the
  487.   gmon library for profiling.  A sample specs file can be found in the
  488.   ``Sample specs file'' section.
  489.  
  490.  
  491.   4.4.  Updating header file links.
  492.  
  493.  
  494.   You need create links in your new include directory to other include
  495.   directories:
  496.  
  497.  
  498.         cd /usr/i486-linuxglibc2/include
  499.         ln -s /usr/src/linux/include/linux
  500.         ln -s /usr/src/linux/include/asm
  501.         ln -s /usr/X11R6/include/X11
  502.  
  503.  
  504.  
  505.  
  506.  
  507.   You might also have other libraries such as ncurses which need their
  508.   header files put in this directory.  You should copy or link the files
  509.   from /usr/include.  (Some libraries may need to be recompiled with
  510.   glibc2 in order to work with it.  In these cases, just compile and
  511.   install the package to /usr/i486-linuxglibc2.)
  512.  
  513.  
  514.   4.5.  Testing your installation.
  515.  
  516.  
  517.   To test the installation, create the following program in a file
  518.   glibc.c:
  519.  
  520.  
  521.         #include <stdio.h>
  522.  
  523.         main()
  524.         {
  525.             printf("hello world!\n");
  526.         }
  527.  
  528.  
  529.   and compile with the options of "-b <base install directory> -nostdinc
  530.   -I<install directory>/include -I/usr/lib/gcc-lib/<new system dir>/<gcc
  531.   version>/include":
  532.  
  533.  
  534.         % 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
  535.  
  536.  
  537.  
  538.  
  539.  
  540.   Use ldd to verify the program was linked with glibc2, and not your old
  541.   libc:
  542.  
  543.  
  544.         % ldd glibc
  545.         libc.so.6 => /usr/i486-linuxglibc2/lib/libc-2.0.6.so (0x4000d000)
  546.         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
  547.  
  548.  
  549.  
  550.  
  551.  
  552.   If it compiles, the links check out, and it generates "hello world!"
  553.   when run, the installation succeeded.
  554.  
  555.  
  556.  
  557.  
  558.   5.  Installing as the primary C library.
  559.  
  560.  
  561.   This section covers installing glibc 2 as your primary C library.  Any
  562.   new programs you compile will be linked with this library, unless you
  563.   use special compile options to link with another version.
  564.  
  565.   If you are are using Redhat or Debian and have downloaded the
  566.   appropriate rpm or deb files, see the Redhat or Debian installion
  567.   instructions.  You can then skip this section.
  568.  
  569.  
  570.  
  571.   5.1.  Building the library from source.
  572.  
  573.  
  574.   This section explains how to compile glibc 2 and add-ons from the
  575.   sources.  You must compile the library if you want to change
  576.   optimization or configuration options or use a package you do not have
  577.   the binaries for.
  578.  
  579.  
  580.   5.1.1.  Prerequisites.
  581.  
  582.  
  583.  
  584.   o  About 150 MB free disk space
  585.  
  586.   o  GNU make 3.75
  587.  
  588.   o  gcc >= 2.7.2 (better 2.7.2.1)
  589.  
  590.   o  binutils 2.8.1 (for alpha you need a snapshot)
  591.  
  592.   o  bash 2.0
  593.  
  594.  
  595.   o  autoconf 2.12 (if you change configure.in)
  596.  
  597.   o  texinfo 3.11
  598.  
  599.   On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile
  600.   with full libraries with add-ons.  On a loaded i686@200, it takes
  601.   about half an hour.
  602.  
  603.  
  604.   5.1.2.  Extracting the source.
  605.  
  606.  
  607.   You need to extract the source from the archives so you can compile
  608.   it.  The best way to do this is:
  609.  
  610.  
  611.         tar xzf glibc-2.0.6.tar.gz
  612.         cd glibc-2.0.6
  613.         tar xzf ../glibc-linuxthreads-2.0.6.tar.gz
  614.         tar xzf ../glibc-crypt-2.0.6.tar.gz
  615.         tar xzf ../glibc-localedata-2.0.6.tar.gz
  616.  
  617.  
  618.  
  619.  
  620.  
  621.   This will put linuxthreads, crypt, and localedata directories in the
  622.   glibc-2.0.6 directory where configure can find these add-ons.
  623.  
  624.  
  625.   5.1.3.  Configuring.
  626.  
  627.  
  628.   In the glibc-2.0.6 directory, create a directory named compile, and cd
  629.   into it.  All work will be done in this directory, which will simplify
  630.   cleaning up.  (The developers have not been very concerned with
  631.   getting 'make clean' perfect yet.)
  632.  
  633.  
  634.        mkdir compile
  635.        cd compile
  636.  
  637.  
  638.  
  639.  
  640.   Run ../configure.  To use the add-on packages, you need to specify
  641.   them with --enable-add-ons, such as --enable-add-ons=linux-
  642.   threads,crypt,localedata.  You probably will also want to specify
  643.   paths where it will be installed.  To match the standard linux distri-
  644.   butions, specify --prefix=/usr.  (When a prefix of /usr is specified
  645.   on a linux system, configure knows to adjust other paths to place
  646.   libc.so and other important libraries in /lib.)  The whole configure
  647.   line would be:
  648.  
  649.  
  650.         ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr
  651.  
  652.  
  653.  
  654.  
  655.  
  656.   5.1.4.  Compiling.
  657.  
  658.  
  659.   To compile and verify, run:
  660.  
  661.    make
  662.    make check
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.   5.2.  Preparing for installation.
  671.  
  672.  
  673.   Now you need to move some files around to prepare for the new library,
  674.   whether you are installing from source or binaries.  Any new program
  675.   compiled will be linked to glibc, but old programs which are not
  676.   statically linked will still depend on libc 5, so you can not just
  677.   overwrite the old version.
  678.  
  679.  
  680.   1. Create a new directory to hold the old files to:
  681.  
  682.  
  683.         mkdir -p /usr/i486-linuxlibc5/lib
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.   2. The old header files must be evacuated from /usr/include:
  691.  
  692.  
  693.         mv /usr/include /usr/i486-linuxlibc5/include
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.   3. Create a new include directory and set up the links to other
  701.      include directories:
  702.  
  703.  
  704.         mkdir /usr/include
  705.  
  706.         ln -s /usr/src/linux/include/linux /usr/include/linux
  707.         ln -s /usr/src/linux/include/asm /usr/include/asm
  708.         ln -s /usr/X11R6/include/X11 /usr/include/X11
  709.         ln -s /usr/lib/g++-include /usr/include/g++
  710.  
  711.  
  712.  
  713.  
  714.  
  715.   The links may need adjusting according to your distribution.  At least
  716.   Slackware puts g++ headers in /usr/local/g++-include, while Debian
  717.   puts the headers in /usr/include/g++, and links /usr/lib/g++-include
  718.   to /usr/include/g++.  In the later case, you probably will want to
  719.   move the original g++ include directory back to /usr/include.
  720.  
  721.   4. Restore any extra header files and links.  Some non-standard
  722.      libraries such as ncurses put files in /usr/include or put a link
  723.      to their include directories in the /usr/include.  These files and
  724.      links need to be restored in order to use the extra libraries
  725.      properly.
  726.  
  727.   5. Add your new library directory (such as /usr/i486-linuxlibc5/lib)
  728.      at the top of your /etc/ld.so.conf file.  You should have ld.so
  729.      1.8.8 or better installed to avoid getting strange messages once
  730.      glibc is installed.
  731.  
  732.   6. Move/copy all the old C libraries into the new directory.
  733.  
  734.  
  735.         mv /usr/lib/libbsd.a /usr/i486-linuxlibc5/lib
  736.         mv /usr/lib/libc.a /usr/i486-linuxlibc5/lib
  737.         mv /usr/lib/libgmon.a /usr/i486-linuxlibc5/lib
  738.         mv /usr/lib/libm.a /usr/i486-linuxlibc5/lib
  739.         mv /usr/lib/libmcheck.a /usr/i486-linuxlibc5/lib
  740.         mv /usr/lib/libc.so /usr/i486-linuxlibc5/lib
  741.         mv /usr/lib/libm.so /usr/i486-linuxlibc5/lib
  742.         cp /lib/libm.so.5.* /usr/i486-linuxlibc5/lib
  743.         cp /lib/libc.so.5.* /usr/i486-linuxlibc5/lib
  744.  
  745.  
  746.  
  747.  
  748.  
  749.   libm.so.5 and libc.so.5 should be copied and not moved if /usr is a
  750.   seperate partition from /, because they are required by programs used
  751.   to start linux and must be located on the root drive partition.
  752.  
  753.   7. Move the /usr/lib/*.o files into the new directory.
  754.  
  755.  
  756.         mv /usr/lib/crt1.o /usr/i486-linuxlibc5/lib
  757.         mv /usr/lib/crti.o /usr/i486-linuxlibc5/lib
  758.         mv /usr/lib/crtn.o /usr/i486-linuxlibc5/lib
  759.         mv /usr/lib/gcrt1.o /usr/i486-linuxlibc5/lib
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.   8. Update your library cache after your libraries are moved.
  767.  
  768.  
  769.         ldconfig -v
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.   5.3.  Installing from the binary package.
  778.  
  779.  
  780.   If you are installing glibc from precompiled binaries, you must:
  781.  
  782.  
  783.         cd /
  784.         gzip -dc glibc-2.0.bin.i386.tar.gz | tar tvvf -
  785.         gzip -dc glibc-crypt-2.0.bin.i386.tar.gz | tar tvvf -
  786.         ldconfig -v
  787.  
  788.  
  789.  
  790.  
  791.  
  792.   If you have a different architecture or version, substitute the proper
  793.   file names.
  794.  
  795.  
  796.  
  797.   5.4.  Installing from the source.
  798.  
  799.  
  800.   To install the library from source, run:
  801.  
  802.  
  803.         make install
  804.         ldconfig -v
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.   5.5.  Updating the gcc specs.
  813.  
  814.  
  815.   The final step of the installation (for both binary and source
  816.   installs) is to update the gcc specs file so you can link your
  817.   programs properly. To determine which specs file is the one used by
  818.   gcc, use:
  819.  
  820.  
  821.         % gcc -v
  822.         reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
  823.         gcc version 2.7.2.2
  824.  
  825.  
  826.  
  827.  
  828.  
  829.   In this case, i486-unknown-linux is the system, and 2.7.2.2 is the
  830.   version.  You need to copy the /usr/lib/gcc-lib/<system> to the old
  831.   system directory:
  832.  
  833.  
  834.         cd /usr/lib/gcc-lib/
  835.         cp -r i486-unknown-linux i486-linuxlibc5
  836.  
  837.  
  838.  
  839.  
  840.  
  841.   Change into the original directory and version directory
  842.  
  843.  
  844.         cd /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2
  845.  
  846.  
  847.  
  848.  
  849.  
  850.   and edit the file specs found in this directory.  In this file, change
  851.   /lib/ld-linux.so.1 to /lib/ld-linux.so.2.  You also need to remove all
  852.   expressions %{...:-lgmon} in the file, since glibc does not use the
  853.   gmon library for profiling.  A sample specs file can be found in the
  854.   ``Sample specs file'' section.
  855.  
  856.  
  857.  
  858.  
  859.   5.6.  Testing your installation.
  860.  
  861.  
  862.   To test the installation, create the following program in a file
  863.   glibc.c:
  864.  
  865.  
  866.         #include <stdio.h>
  867.  
  868.         main()
  869.         {
  870.             printf("hello world!\n");
  871.         }
  872.  
  873.  
  874.  
  875.  
  876.  
  877.   and compile the program.
  878.  
  879.  
  880.         % gcc glibc.c -o glibc
  881.  
  882.  
  883.  
  884.  
  885.  
  886.   Use ldd to verify the program was linked with glibc2, and not your old
  887.   libc:
  888.  
  889.  
  890.         % ldd glibc
  891.         libc.so.6 => /lib/libc.so.6 (0x4000e000)
  892.         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
  893.  
  894.  
  895.  
  896.  
  897.  
  898.   If this compiles and generates "hello world!" when run, the installa-
  899.   tion was successful.
  900.  
  901.  
  902.  
  903.  
  904.   6.  Compiling with the non-primary libc.
  905.  
  906.  
  907.   There are times you will want to use an alternate library to compile
  908.   your programs with.  This section explains how to accomplish this,
  909.   using the directories and installation names used in the examples in
  910.   the previous two sections.  Remember to change the names to fit your
  911.   setup.
  912.  
  913.  
  914.   6.1.  A warning when using non-primary libcs.
  915.  
  916.   Before compiling any programs which is used in the system boot
  917.   process, remember that if the program is dynamically linked and is
  918.   used before the non-root partitions are mounted, all linked libraries
  919.   must be on the root partition.  Following the installation process in
  920.   the previous section for installing glibc as your primary C library,
  921.   the old libc is left in /lib, which will be on your root partition.
  922.   This means all of your programs will still work during booting.
  923.   However, if /usr is on a different partition and you install glibc as
  924.   a test library in /usr/i486-linuxglibc2, any new programs you compile
  925.   with glibc will not work until your /usr partition is mounted.
  926.  
  927.  
  928.   6.2.  Compiling programs with a test glibc.
  929.  
  930.   To compile a program with a test-install glibc, you need to reset the
  931.   include paths to point to the glibc includes.  Specifying "-nostdinc"
  932.   will negate the normal paths, and "-I/usr/i486-linuxglibc2/include"
  933.   will point to the glibc includes.  You will also need to specify the
  934.   gcc includes, which are found in /usr/lib/gcc-
  935.   lib/i486-linuxglibc2/2.7.2.2/include (assuming you installed the test
  936.   lib in i486-linuxglibc2 with gcc version 2.7.2.2).
  937.  
  938.   To link a program with a test-install glibc, you need to specify the
  939.   gcc setup.  This is done by using the option "-b i486-linuxglibc2".
  940.  
  941.   For most programs, you can specify these new options by adding them to
  942.   the $CFLAGS and $LDFLAGS makefile options:
  943.  
  944.  
  945.         CFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -b i486-linuxglibc2
  946.         LDFLAGS = -b i486-linuxglibc2
  947.  
  948.  
  949.  
  950.  
  951.  
  952.   If you are using a configure script, define the $CFLAGS and $LDFLAGS
  953.   shell variables (by using env/setenv for csh/tcsh, or set/export for
  954.   sh/bash/etc) before running configure.  The makefiles generated by
  955.   this should contain the proper $CFLAGS and $LDFLAGS.  Not all config-
  956.   ure scripts will pick up the variables, so you should check after run-
  957.   ning configure and edit the makefiles by hand if necessary.
  958.  
  959.   If the programs you are compiling only call gcc (and not cpp or
  960.   binutils directly), you can use the following script to save having to
  961.   specify all of the options each time:
  962.  
  963.  
  964.         #!/bin/bash
  965.         /usr/bin/gcc -b i486-linuxglibc2 -nostdinc \
  966.                      -I/usr/i486-linuxglibc2/include \
  967.                      -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include "$@"
  968.  
  969.  
  970.  
  971.  
  972.  
  973.   You can then use this script instead of "gcc" when compiling.
  974.  
  975.  
  976.   6.3.  Compiling programs with libc 5 when glibc is primary library.
  977.  
  978.   To compile a program with your old libraries when you have installed
  979.   glibc as your main library, you need to reset the include paths to the
  980.   old includes.  Specifying "-nostdinc" will negate the normal paths,
  981.   and "-I/usr/i486-linuxlibc5/include" will point to the glibc includes.
  982.   You must also specify "-I/usr/lib/gcc-
  983.   lib/i486-linuxlibc5/2.7.2.2/include" to include the gcc specific
  984.   includes.  Remember to adjust these paths based on the what you named
  985.   the new directories and your gcc version.
  986.  
  987.   To link a program with your old libc, you need to specify the gcc
  988.   setup.  This is done by using the option "-b i486-linuxlibc5".
  989.  
  990.  
  991.   For most programs, you can specify these new options by appending them
  992.   to the $CFLAGS and $LDFLAGS makefile options:
  993.  
  994.  
  995.         CFLAGS = -nostdinc -I/usr/i486-linuxlibc5/include -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include -b i486-linuxlibc5
  996.         LDFLAGS = -b i486-linuxlibc5
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.   If you are using a configure script, define the $CFLAGS and $LDFLAGS
  1003.   shell variables (by using env/setenv for csh/tcsh, or set/export for
  1004.   sh/bash/etc) before running configure.  The makefiles generated by
  1005.   this should contain the proper $CFLAGS and $LDFLAGS.  Not all config-
  1006.   ure scripts will pick up the variables, so you should check after run-
  1007.   ning configure and edit the makefiles by hand if necessary.
  1008.  
  1009.   If the programs you are compiling only call gcc (and not cpp or
  1010.   binutils directly), you can use the following script to save having to
  1011.   specify all of the options each time:
  1012.  
  1013.  
  1014.         #!/bin/bash
  1015.         /usr/bin/gcc -b i486-linuxlibc5 -nostdinc \
  1016.                      -I/usr/i486-linuxlibc5/include \
  1017.                      -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include "$@"
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.   You can then use this script instead of "gcc" when compiling.
  1024.  
  1025.  
  1026.  
  1027.   7.  Compiling C++ programs.
  1028.  
  1029.  
  1030.   Libg++ uses parts of the math library, so is link to libm.  Since your
  1031.   existing libg++ will be compiled with your old library, you will have
  1032.   to recompile libg++ with glibc or get a binary copy.  The latest
  1033.   source for libg++ along with a binary linked with glibc (for x86) can
  1034.   be found at <ftp://ftp.yggdrasil.com/private/hjl/>.
  1035.  
  1036.  
  1037.   7.1.  Installing libg++ for a test glibc install.
  1038.  
  1039.   If you have installed glibc as a test library, you need to install the
  1040.   files into the directory you installed glibc into (such as
  1041.   /usr/i486-linuxglibc2 for the example in the previous sections).  If
  1042.   you are installing from the binary package (which i would recommend,
  1043.   since i never had any luck compiling libg++ this way), you need to
  1044.   extract the files into a temporary directory and move all the usr/lib/
  1045.   files into the <install directory>/lib/ directory, the usr/include/
  1046.   files into the <install directory>/include/ directory (remember to
  1047.   delete your include/g++ link first!), and the usr/bin/ files into the
  1048.   <install directory>/bin/ directory.
  1049.  
  1050.  
  1051.   7.2.  Installing libg++ for a primary glibc install.
  1052.  
  1053.   If you have installed glibc as the primary library, you first need to
  1054.   move your old libg++ files into your old libc directory if you still
  1055.   want to be able to compile g++ programs with your old libc.  Probably
  1056.   the easiest way to do this is by installing a new copy of the libg++
  1057.   compiled with libc 5 as in the previous section, and then installing
  1058.   the glibc version normally.
  1059.  
  1060.  
  1061.   7.3.  Compiling C++ programs with the non-primary libc.
  1062.  
  1063.   If you are trying to compile a C++ program with a non-primary libc,
  1064.   you will need to include the g++ include dir, which in the examples
  1065.   above would be /usr/i486-linuxglibc2/include/g++ for a test glibc
  1066.   install or /usr/i486-linuxlibc5/include/g++ for a primary glibc
  1067.   install.  This can usually be done by appending the $CXXFLAGS
  1068.   variable:
  1069.  
  1070.  
  1071.         CXXFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -I/usr/i486-linuxlibc5/include/g++ -b i486-linuxglibc2
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.   8.  Reporting bugs.
  1080.  
  1081.  
  1082.   If you think the lib is buggy, please read first the FAQ. It might be
  1083.   that others had the same problem and there's an easy solution. You
  1084.   should also check the section "Recommended Tools to Install the GNU C
  1085.   Library" in the INSTALL file since some bugs are bugs of the tools and
  1086.   not of glibc.
  1087.  
  1088.   Once you've found a bug, make sure it's really a bug. A good way to do
  1089.   this is to see if the GNU C library behaves the same way some other C
  1090.   library does. If so, probably you are wrong and the libraries are
  1091.   right (but not necessarily). If not, one of the libraries is probably
  1092.   wrong.
  1093.  
  1094.   Next, go to  <http://www-gnats.gnu.org:8080/cgi-bin/wwwgnats.pl>, and
  1095.   look through the bug database.  Check here to verify the problem has
  1096.   not already be reported. You should also look at the file BUGS
  1097.   (distributed with libc) to check for known bugs.
  1098.  
  1099.   Once you're sure you've found a new bug, try to narrow it down to the
  1100.   smallest test case that reproduces the problem. In the case of a C
  1101.   library, you really only need to narrow it down to one library
  1102.   function call, if possible.  This should not be too difficult.
  1103.  
  1104.   The final step when you have a simple test case is to report the bug.
  1105.   When reporting a bug, send your test case, the results you got, the
  1106.   results you expected, what you think the problem might be (if you've
  1107.   thought of anything), your system type, the versions of the GNU C
  1108.   library, the GNU CC compiler, and the GNU Binutils which you are
  1109.   using.  Also include the files config.status and config.make which are
  1110.   created by running configure; they will be in whatever directory was
  1111.   current when you ran configure.
  1112.  
  1113.   All bug reports for the GNU C library should be sent using the
  1114.   glibcbug shell script which comes with the GNU libc to <bugs@gnu.org>
  1115.   (the older address  <bugs@gnu.ai.mit.edu> is still working), or
  1116.   submitted through the GNATS web interface at <http://www-
  1117.   gnats.gnu.org:8080/cgi-bin/wwwgnats.pl>.
  1118.  
  1119.   Suggestions and questions should be sent to the mailing list at <bugs-
  1120.   glibc@prep.ai.mit.edu>.  If you don't read the gnewsgroup
  1121.   gnu.bug.glibc, you can subscribe to the list by asking  <bug-glibc-
  1122.   request@prep.ai.mit.edu>.
  1123.   Please DO NOT send bug report for the GNU C library to <bug-
  1124.   gcc@prep.ai.mit.edu>.  That list is for bug reports for GNU CC.  GNU
  1125.   CC and the GNU C library are separate entities maintained by separate
  1126.   people.
  1127.  
  1128.  
  1129.  
  1130.   9.  Sample specs file.
  1131.  
  1132.  
  1133.   Included here is a sample specs file for glibc 2 which is used by gcc
  1134.   for compiling and linking.  It should be found in the directory
  1135.   /usr/lib/gcc-lib/<new system dir>/<gcc version>.  If you are running
  1136.   an x86 system, you probably can copy this section to the file exactly.
  1137.  
  1138.  
  1139.         *asm:
  1140.         %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
  1141.  
  1142.         *asm_final:
  1143.         %{pipe:-}
  1144.  
  1145.         *cpp:
  1146.         %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
  1147.  
  1148.         *cc1:
  1149.         %{profile:-p}
  1150.  
  1151.         *cc1plus:
  1152.  
  1153.  
  1154.         *endfile:
  1155.         %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
  1156.  
  1157.         *link:
  1158.         -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:       %{rdynamic:-export-dynamic}     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}
  1159.  
  1160.         *lib:
  1161.         %{!shared: %{pthread:-lpthread}        %{profile:-lc_p} %{!profile: -lc}}
  1162.  
  1163.         *libgcc:
  1164.         -lgcc
  1165.  
  1166.         *startfile:
  1167.         %{!shared:      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}                  %{!p:%{profile:gcrt1.o%s}                         %{!profile:crt1.o%s}}}}    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
  1168.  
  1169.         *switches_need_spaces:
  1170.  
  1171.  
  1172.         *signed_char:
  1173.         %{funsigned-char:-D__CHAR_UNSIGNED__}
  1174.  
  1175.         *predefines:
  1176.         -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
  1177.  
  1178.         *cross_compile:
  1179.         0
  1180.  
  1181.         *multilib:
  1182.         . ;
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.   10.  Miscellanea.
  1190.  
  1191.  
  1192.  
  1193.   10.1.  Further information.
  1194.  
  1195.  
  1196.  
  1197.   10.1.1.  Web pages.
  1198.  
  1199.  
  1200.  
  1201.   o  FSF's GNU C Library Home Page
  1202.      <http://www.gnu.org/software/libc/libc.html>
  1203.  
  1204.   o  Using GNU Libc 2 with Linux <http://www.imaxx.net/~thrytis/glibc/>
  1205.  
  1206.   o  Installing glibc-2 on Linux <http://huizen.dds.nl/~frodol/glibc/>.
  1207.  
  1208.   o  Debian libc5 to libc6 Mini-HOWTO
  1209.      <http://www.gate.net/~storm/FAQ/libc5-libc6-Mini-HOWTO.html>.
  1210.  
  1211.  
  1212.   10.1.2.  Newgroups.
  1213.  
  1214.  
  1215.  
  1216.   o  comp.os.linux.development.system
  1217.  
  1218.   o  comp.os.linux.development.apps
  1219.  
  1220.   o  linux.dev.kernel
  1221.  
  1222.   o  gnu.bugs.glibc
  1223.  
  1224.  
  1225.   10.1.3.  Mailing lists.
  1226.  
  1227.  
  1228.  
  1229.      Glibc 2 Linux discussion list.
  1230.         This list is intended for discussion among Linux users who have
  1231.         installed glibc2, the new GNU C libraries.  Topics might include
  1232.         compatibility issues and questions about the compilation of code
  1233.         in a Linux/glibc setting.  To subscribe, send mail to
  1234.         Majordomo@ricardo.ecn.wfu.edu
  1235.         <mailto:Majordomo@ricardo.ecn.wfu.edu> with a body of "subscribe
  1236.         glibc-linux <your email address>.
  1237.  
  1238.  
  1239.   10.2.  Credits.
  1240.  
  1241.  
  1242.   Most of this information was stolen from the GNU Libc web page
  1243.   <http://www.gnu.org/software/libc/libc.html> and from Ulrich Drepper's
  1244.   <drepper@gnu.ai.mit.edu> glibc 2 announcement and his comments.
  1245.   Andreas Jaeger <aj@arthur.rhein-neckar.de> provided some of the
  1246.   Reporting bugs section.
  1247.  
  1248.   The following people have provided information and feedback for this
  1249.   document:
  1250.  
  1251.   o  Allex <allex@ms2.accmail.com.tw>
  1252.  
  1253.   o  Mark Brown <M.A.Brown-4@sms.ed.ac.uk>
  1254.  
  1255.   o  Ulrich Drepper <drepper@gnu.ai.mit.edu>
  1256.  
  1257.   o  Scott K. Ellis <ellis@valueweb.net>
  1258.  
  1259.   o  Aron Griffis <agriffis@coat.com>
  1260.  
  1261.   o  Andreas Jaeger <aj@arthur.rhein-neckar.de>
  1262.  
  1263.   o  Frodo Looijaard <frodol@dds.nl>
  1264.  
  1265.   o  Ryan McGuire <rmcguire@freenet.columbus.oh.us>
  1266.  
  1267.   o  Shaya Potter <spotter@capaccess.org>
  1268.  
  1269.   o  Les Schaffer <godzilla@futuris.net>
  1270.  
  1271.   o  Andy Sewell <puck@pookhill.demon.co.uk>
  1272.  
  1273.   o  Gary Shea <shea@gtsdesign.com>
  1274.  
  1275.   o  Stephane <sr@adb.fr>
  1276.  
  1277.   o  Jan Vandenbos <jan@imaxx.net>
  1278.  
  1279.   Translations of this document are being done by:
  1280.  
  1281.   o  Chinese: Allex <allex@ms2.accmail.com.tw>
  1282.  
  1283.   o  French:  Olivier Tharan <tharan@int-evry.fr>
  1284.  
  1285.   o  Japanese:  Kazuyuki Okamoto <ikko-@pacific.rim.or.jp>
  1286.  
  1287.  
  1288.  
  1289.   10.3.  Feedback.
  1290.  
  1291.  
  1292.   Besides writing this HOWTO, maintaining the glibc 2 for Linux
  1293.   <http://www.imaxx.net/~thrytis/glibc> page, and using it on my
  1294.   machine, I have nothing to do with the glibc project.  I am far from
  1295.   knowledgeable on this topic, though I try to help with problems mailed
  1296.   to me.  I welcome any feedback, corrections, or suggestions you have
  1297.   to offer.  Please send them to ejg3@cornell.edu
  1298.   <mailto:ejg3@cornell.edu>.
  1299.  
  1300.  
  1301.   10.4.  Copyright.
  1302.  
  1303.   Copyright (c) 1997 by Eric Green.  This document may be distributed
  1304.   under the terms set forth in the LDP license.
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.