home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 11 / IOPROG_11.ISO / docs / glibc2~1 < prev    next >
Encoding:
Text File  |  1997-10-07  |  29.3 KB  |  801 lines

  1.   Glibc 2 HOWTO
  2.   Eric Green, thrytis@imaxx.net
  3.   v1.0, 31 August 1997
  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.   1.  Introduction
  9.  
  10.   1.1.  About glibc 2
  11.  
  12.   Glibc 2 is the latest version of the GNU C Library. It currently runs
  13.   unmodified on GNU Hurd systems and Linux i386, m68k, and alpha
  14.   systems.  Ports to Linux PowerPC, MIPS, and Sparc are actively being
  15.   developed.  In the future support for other architectures and
  16.   operating systems will be added.
  17.  
  18.   On Linux, glibc 2 is used as the libc with major version 6, the
  19.   successor of the Linux libc 5.  It is intended by the Linux libc
  20.   developers to eventually replace libc 5.  It is currently
  21.   experimental, but is stable enough to be used by people interested in
  22.   testing it and willing to put a little extra effort to get things
  23.   working.  The latest version is actually quite stable if the program
  24.   you are using supports it.
  25.  
  26.   There are three optional add-ons available for glibc 2:
  27.  
  28.      Crypt
  29.         The UFC-crypt package.  It is seperate  because of export
  30.         restrictions.
  31.  
  32.      LinuxThreads
  33.         An implementation of the Posix 1003.1c "pthread" interface.
  34.  
  35.      Locale data
  36.         Contains the data needed to build the locale data files to use
  37.         the internationalization features of the glibc.
  38.  
  39.   1.2.  About this document
  40.  
  41.   This HOWTO covers installing the glibc 2 library on an existing Linux
  42.   system.  It is tailored for users of Intel based systems currently
  43.   using libc 5, but users of other systems and alternate libraries (such
  44.   as glibc 1) should be able to use this information by substituting the
  45.   proper filenames and architecture names in the appropriate places.
  46.  
  47.   The latest copy of this HOWTO can be found at
  48.   <http://www.imaxx.net/~thrytis/glibc/Glibc2-HOWTO.html>, or you can
  49.   get a text version at
  50.   <http://www.imaxx.net/~thrytis/glibc/Glibc2-HOWTO.txt>
  51.  
  52.   1.3.  Recent changes in this document
  53.  
  54.   Differences between version 0.9.1 and 1.0:
  55.  
  56.   ╖  Updated glibc version to 2.0.5.
  57.  
  58.   ╖  Added information on Red Hat 4.8.
  59.  
  60.   2.  Choosing your installation method
  61.  
  62.   There are two ways to install glibc.  You can install the libraries as
  63.   a test, using the existing libraries as the default but letting you
  64.   try the new libraries by using different options when compiling your
  65.   program.  Installing in this way also makes it easy to remove glibc in
  66.   the future (though any program linked with glibc will no longer work
  67.   after the libraries are removed). Using glibc as a test library
  68.   requires you to compile the libraries from source.  There is no binary
  69.   distribution for installing libraries this way.  This installation is
  70.   described in ``Installing as a test library''.
  71.  
  72.   The other way to install is using glibc as your primary library.  All
  73.   new programs that you compile on your system will use glibc, though
  74.   you can link programs with your old libraries using different options
  75.   while compiling.  You can either install the libraries from binaries,
  76.   or compile the library yourself.  If you want to change optimization
  77.   or configuration options, or use an add-on which is not distributed as
  78.   a binary package, you must get the source distribution and compile.
  79.   This installation procedure is described in ``Installing as the
  80.   primary C library''.
  81.  
  82.   If you are installing glibc 2 on an important system, you should not
  83.   install it as your primary library.  Use the test install, or better,
  84.   try it on a spare system.
  85.  
  86.   3.  Getting the library
  87.  
  88.   The glibc 2 consists of the glibc package and three optional add-on
  89.   packages, LinuxThreads, Locale, and Crypt.  The source can be found at
  90.  
  91.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.5.tar.gz>
  92.  
  93.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-linuxthreads-2.0.5.tar.gz>
  94.  
  95.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-localedata-2.0.5.tar.gz>
  96.  
  97.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.5.tar.gz>
  98.  
  99.   It will take about 150 MB of disk space for the full compile and
  100.   install.  The basic binary install of just the core library package is
  101.   about 50 MB.
  102.  
  103.   Binary packages for 2.0.5 are not available.  Version 2.0.4 binary
  104.   packages are available for i386, alpha, and 68k, and can be found at
  105.  
  106.   ╖  Intel x86:
  107.  
  108.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.4.bin.i386.tar.gz>
  109.  
  110.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.4.bin.i386.tar.gz>
  111.  
  112.   ╖  Alpha:
  113.  
  114.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.1.bin.alpha-linux.tar.gz>
  115.  
  116.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.1.bin.alpha-
  117.      linux.tar.gz>
  118.  
  119.   ╖  m68k:
  120.  
  121.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.4-m68k-linux.bin.tar.gz>
  122.  
  123.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.4-m68k-
  124.      linux.bin.tar.gz>
  125.  
  126.      There are export restrictions on the crypt add-on.  Non-US users
  127.      should get it from  <ftp://ftp.ifi.uio.no/pub/gnu>.
  128.  
  129.   If you are running a Red Hat distribution, you can get rpms for glibc
  130.   2 from <ftp://ftp.redhat.com/pub/redhat/tbird/RedHat/RPMS/>.  Glibc 2
  131.   is the primary C library for the new beta Red Hat distribution 4.8.
  132.  
  133.   If you are running a Debian distribution, you can get the packages for
  134.   glibc 2 from  <ftp://ftp.debian.org/debian/unstable/binary-
  135.   i386/devel/>, <ftp://ftp.debian.org/debian/unstable/binary-
  136.   m68k/devel/>, or <ftp://ftp.debian.org/debian/unstable/binary-
  137.   alpha/devel/>.  The files are named libc6.  Glibc 2 is now part of the
  138.   base package of the hamm version of Debian, and will be the primary
  139.   libc when Debian 2.0 is released.
  140.  
  141.   4.  Installing as a test library
  142.  
  143.   This section covers installing glibc 2 as a test library.  Anything
  144.   you compile will be linked to your existing libraries unless you give
  145.   some extra parameters to link to the new libraries.  It appears that
  146.   the paths are compiled into quite a few files, so you probably have to
  147.   install the library from source.
  148.  
  149.   4.1.  Compiling and installing
  150.  
  151.   4.1.1.  Prerequisites
  152.  
  153.   ╖  About 150 MB free disk space
  154.  
  155.   ╖  GNU make 3.75
  156.  
  157.   ╖  gcc >= 2.7.2 (better 2.7.2.1)
  158.  
  159.   ╖  binutils 2.8.1 (for alpha you need a snapshot)
  160.  
  161.   ╖  bash-2.0
  162.  
  163.   ╖  autoconf-2.12 (if you change configure.in)
  164.  
  165.   On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile
  166.   with full libraries with add-ons.  On a loaded i686@200, it takes
  167.   about half an hour.
  168.  
  169.   4.1.2.  Extracting the source
  170.  
  171.   You need to extract the source from the archives so you can compile
  172.   it.  The best way to do this is:
  173.  
  174.    tar xzf glibc-2.0.5.tar.gz
  175.    cd glibc-2.0.5
  176.    tar xzf ../glibc-linuxthreads-2.0.5.tar.gz
  177.    tar xzf ../glibc-crypt-2.0.5.tar.gz
  178.    tar xzf ../glibc-localedata-2.0.5.tar.gz
  179.  
  180.   This will put linuxthreads, crypt, and localedata directories in the
  181.   glibc-2.0.5 directory where configure can find these add-ons.
  182.  
  183.   4.1.3.  Configuring
  184.  
  185.   In the glibc-2.0.5 directory, create a directory named compile, and cd
  186.   into it.  All work will be done in this directory, which will simplify
  187.   cleaning up.  (The developers have not been very concerned with
  188.   getting 'make clean' perfect yet.)
  189.  
  190.         mkdir compile
  191.         cd compile
  192.  
  193.   Run ../configure.  To use the add-on packages, you need to specify
  194.   them with --enable-add-ons, such as --enable-add-
  195.   ons=linuxthreads,crypt,localedata.  You also need to choose a destina¡
  196.   tion directory to install to.  /usr/i486-linuxglibc2 is a good choice.
  197.   The configure line for this would be:
  198.  
  199.         ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr/i486-linuxglibc2
  200.  
  201.   4.1.4.  Compiling and installing
  202.  
  203.   To compile and verify, run:
  204.  
  205.         make
  206.         make check
  207.  
  208.   If the 'make check' succeeds, install the library:
  209.  
  210.         make install
  211.  
  212.   4.2.  Updating the dynamic loader
  213.  
  214.   1. Create a link from the new ld.so to /lib/ld-linux.so.2:
  215.  
  216.         ln -s /usr/i486-linuxglibc2/lib/ld-linux.so.2 /lib/ld-linux.so.2
  217.  
  218.   This is the only library where the location is fixed once a program is
  219.   linked, and using a link in /lib will ease upgrading to glibc as your
  220.   primary C library when the stable version is released.
  221.  
  222.   2. Edit /etc/ld.so.conf.  You need to add path to the lib directory
  223.      the new libraries reside in at the end of the file, which will be
  224.      <prefix>/lib, such as /usr/i486-linuxglibc2/lib for the choice
  225.      above.  After you have modified /etc/ld.so.conf, run
  226.  
  227.         ldconfig -v
  228.  
  229.   4.3.  Configuring for gcc
  230.  
  231.   The last step of installation is updating /usr/lib/gcc-lib so gcc
  232.   knows how to use the new libraries.  First you need to duplicate the
  233.   existing configuration.  To find out which configuration is current,
  234.   use the -v option of gcc:
  235.  
  236.         % gcc -v
  237.         Reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
  238.         gcc version 2.7.2.2
  239.  
  240.   In this case, i486-unknown-linux is the system, and 2.7.2.2 is the
  241.   version.  You need to copy the /usr/lib/gcc-lib/<system> to the new
  242.   test system directory:
  243.  
  244.         cd /usr/lib/gcc-lib/
  245.         cp -r i486-unknown-linux i486-linuxglibc2
  246.  
  247.   Change into your new test system directory and version directory
  248.  
  249.         cd /usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2
  250.  
  251.   and edit the file 'specs' found in this directory.  In this file,
  252.   change /lib/ld-linux.so.1 to /lib/ld-linux.so.2.  You also need to
  253.   remove all expressions %{...:-lgmon} in the file, since glibc does not
  254.   use the gmon library for profiling.  A sample specs file can be found
  255.   in the ``Sample specs file'' section.
  256.  
  257.   4.4.  Updating header file links
  258.  
  259.   You need create links in your new include directory to other include
  260.   directories:
  261.  
  262.         cd /usr/i486-linuxglibc2/include
  263.         ln -s /usr/src/linux/include/linux
  264.         ln -s /usr/src/linux/include/asm
  265.         ln -s /usr/X11R6/include/X11
  266.  
  267.   You might also have other libraries such as ncurses which need their
  268.   header files put in this directory.  You should copy or link the files
  269.   from /usr/include.  (Some libraries may need to be recompiled with
  270.   glibc2 in order to work with it.  In these cases, just compile and
  271.   install the package to /usr/i486-linuxglibc2.)
  272.  
  273.   4.5.  Testing your installation
  274.  
  275.   To test the installation, create the following program in a file
  276.   glibc.c:
  277.  
  278.         #include <stdio.h>
  279.  
  280.         main()
  281.         {
  282.             printf("hello world!\n");
  283.         }
  284.  
  285.   and compile with the options of "-b <base install directory> -nostdinc
  286.   -I<install directory>/include -I/usr/lib/gcc-lib/<new system dir>/<gcc
  287.   version>/include":
  288.  
  289.         % 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
  290.  
  291.   Use ldd to verify the program was linked with glibc2, and not your old
  292.   libc:
  293.  
  294.    % ldd glibc
  295.    libc.so.6 => /usr/i486-linuxglibc2/lib/libc-2.0.5.so (0x4000d000)
  296.    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
  297.  
  298.   If it compiles, the links check out, and it generates "hello world!"
  299.   when run, the installation succeeded.
  300.  
  301.   5.  Installing as the primary C library
  302.  
  303.   This section covers installing glibc 2 as your primary C library.  Any
  304.   new programs you compile will be linked with this library, unless you
  305.   use special compile options to link with another version.
  306.  
  307.   If you are are using Redhat or Debian and have downloaded the
  308.   appropriate rpm or deb files, see the Redhat or Debian installion
  309.   instructions.  You can then skip this section.
  310.  
  311.   5.1.  Building the library from source
  312.  
  313.   This section explains how to compile glibc 2 and add-ons from the
  314.   sources.  You must compile the library if you want to change
  315.   optimization or configuration options or use a package you do not have
  316.   the binaries for.
  317.  
  318.   5.1.1.  Prerequisites
  319.  
  320.   ╖  About 150 MB free disk space
  321.  
  322.   ╖  GNU make 3.75
  323.  
  324.   ╖  gcc >= 2.7.2 (better 2.7.2.1)
  325.  
  326.   ╖  binutils 2.8.1 (for alpha you need a snapshot)
  327.  
  328.   ╖  bash-2.0
  329.  
  330.   ╖  autoconf-2.12 (if you change configure.in)
  331.  
  332.   On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile
  333.   with full libraries with add-ons.  On a loaded i686@200, it takes
  334.   about half an hour.
  335.  
  336.   5.1.2.  Extracting the source
  337.  
  338.   You need to extract the source from the archives so you can compile
  339.   it.  The best way to do this is:
  340.  
  341.    tar xzf glibc-2.0.5.tar.gz
  342.    cd glibc-2.0.5
  343.    tar xzf ../glibc-linuxthreads-2.0.5.tar.gz
  344.    tar xzf ../glibc-crypt-2.0.5.tar.gz
  345.    tar xzf ../glibc-localedata-2.0.5.tar.gz
  346.  
  347.   This will put linuxthreads, crypt, and localedata directories in the
  348.   glibc-2.0.5 directory where configure can find these add-ons.
  349.  
  350.   5.1.3.  Configuring
  351.  
  352.   In the glibc-2.0.5 directory, create a directory named compile, and cd
  353.   into it.  All work will be done in this directory, which will simplify
  354.   cleaning up.  (The developers have not been very concerned with
  355.   getting 'make clean' perfect yet.)
  356.  
  357.        mkdir compile
  358.        cd compile
  359.  
  360.   Run ../configure.  To use the add-on packages, you need to specify
  361.   them with --enable-add-ons, such as --enable-add-
  362.   ons=linuxthreads,crypt,localedata.  You probably will also want to
  363.   specify paths where it will be installed.  To match the standard linux
  364.   distributions, specify --prefix=/usr.  (When a prefix of /usr is spec¡
  365.   ified on a linux system, configure knows to adjust other paths to
  366.   place libc.so and other important libraries in /lib.)  The whole con¡
  367.   figure line would be:
  368.  
  369.         ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr
  370.  
  371.   5.1.4.  Compiling
  372.  
  373.   To compile and verify, run:
  374.  
  375.         make
  376.         make check
  377.  
  378.   5.2.  Preparing for installation
  379.  
  380.   Now you need to move some files around to prepare for the new library,
  381.   whether you are installing from source or binaries.  Any new program
  382.   compiled will be linked to glibc, but old programs which are not
  383.   statically linked will still depend on libc 5, so you can not just
  384.   overwrite the old version.
  385.  
  386.   1. Create a new directory to hold the old files to:
  387.  
  388.         mkdir -p /usr/i486-linuxlibc5/lib
  389.  
  390.   2. The old header files must be evacuated from /usr/include:
  391.  
  392.         mv /usr/include /usr/i486-linuxlibc5/include
  393.  
  394.   3. Create a new include directory and set up the links to other
  395.      include directories:
  396.  
  397.         mkdir /usr/include
  398.  
  399.         ln -s /usr/src/linux/include/linux /usr/include/linux
  400.         ln -s /usr/src/linux/include/asm /usr/include/asm
  401.         ln -s /usr/X11R6/include/X11 /usr/include/X11
  402.         ln -s /usr/lib/g++-include /usr/include/g++
  403.  
  404.   The links may need adjusting according to your distribution.  At least
  405.   Slackware puts g++ headers in /usr/local/g++-include, while debian
  406.   puts the headers in /usr/include/g++, and links /usr/lib/g++-include
  407.   to /usr/include/g++.  In the later case, you probably will want to
  408.   move the original g++ include directory back to /usr/include.
  409.  
  410.   4. Restore any extra header files and links.  Some non-standard
  411.      libraries such as ncurses put files in /usr/include or put a link
  412.      to their include directories in the /usr/include.  These files and
  413.      links need to be restored in order to use the extra libraries
  414.      properly.
  415.  
  416.   5. Add your new library directory (such as /usr/i486-linuxlibc5/lib)
  417.      at the top of your /etc/ld.so.conf file.  You should have
  418.      ld.so-1.8.8 or better installed to avoid getting strange messages
  419.      once glibc is installed.
  420.  
  421.   6. Move/copy all the old C libraries into the new directory.
  422.  
  423.    mv /usr/lib/libbsd.a /usr/i486-linuxlibc5/lib
  424.    mv /usr/lib/libc.a /usr/i486-linuxlibc5/lib
  425.    mv /usr/lib/libgmon.a /usr/i486-linuxlibc5/lib
  426.    mv /usr/lib/libm.a /usr/i486-linuxlibc5/lib
  427.    mv /usr/lib/libmcheck.a /usr/i486-linuxlibc5/lib
  428.    mv /usr/lib/libc.so /usr/i486-linuxlibc5/lib
  429.    mv /usr/lib/libm.so /usr/i486-linuxlibc5/lib
  430.    cp /lib/libm.so.5.* /usr/i486-linuxlibc5/lib
  431.    cp /lib/libc.so.5.* /usr/i486-linuxlibc5/lib
  432.  
  433.   libm.so.5 and libc.so.5 should be copied and not moved if /usr is a
  434.   seperate partition from /, because they are required by programs used
  435.   to start linux and must be located on the root drive partition.
  436.  
  437.   7. Move the /usr/lib/*.o files into the new directory.
  438.  
  439.         mv /usr/lib/crt1.o /usr/i486-linuxlibc5/lib
  440.         mv /usr/lib/crti.o /usr/i486-linuxlibc5/lib
  441.         mv /usr/lib/crtn.o /usr/i486-linuxlibc5/lib
  442.         mv /usr/lib/gcrt1.o /usr/i486-linuxlibc5/lib
  443.  
  444.   8. Update your library cache after your libraries are moved.
  445.  
  446.         ldconfig -v
  447.  
  448.   5.3.  Installing from the binary package
  449.  
  450.   If you are installing glibc from precompiled binaries, you must:
  451.  
  452.         cd /
  453.         gzip -dc glibc-2.0.bin.i386.tar.gz | tar tvvf -
  454.         gzip -dc glibc-crypt-2.0.bin.i386.tar.gz | tar tvvf -
  455.         ldconfig -v
  456.  
  457.   If you have a different architecture or version, substitute the proper
  458.   file names.
  459.  
  460.   5.4.  Installing from the source
  461.  
  462.   To install the library from source, run:
  463.  
  464.         make install
  465.         ldconfig -v
  466.  
  467.   5.5.  Updating the gcc specs
  468.  
  469.   The final step of the installation (for both binary and source
  470.   installs) is to update the gcc specs file so you can link your
  471.   programs properly.  To determine which specs file is the one used by
  472.   gcc, use:
  473.  
  474.         % gcc -v
  475.         reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
  476.         gcc version 2.7.2.2
  477.  
  478.   In this case, i486-unknown-linux is the system, and 2.7.2.2 is the
  479.   version.  You need to copy the /usr/lib/gcc-lib/<system> to the old
  480.   system directory:
  481.  
  482.         cd /usr/lib/gcc-lib/
  483.         cp -r i486-unknown-linux i486-linuxlibc5
  484.  
  485.   Change into the original directory and version directory
  486.  
  487.         cd /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2
  488.  
  489.   and edit the file 'specs' found in this directory.  In this file,
  490.   change /lib/ld-linux.so.1 to /lib/ld-linux.so.2.  You also need to
  491.   remove all expressions %{...:-lgmon} in the file, since glibc does not
  492.   use the gmon library for profiling.  A sample specs file can be found
  493.   in the ``Sample specs file'' section.
  494.  
  495.   5.6.  Testing your installation
  496.  
  497.   To test the installation, create the following program in a file
  498.   glibc.c:
  499.  
  500.    #include <stdio.h>
  501.  
  502.    main()
  503.    {
  504.        printf("hello world!\n");
  505.    }
  506.  
  507.   and compile the program.
  508.  
  509.         % gcc glibc.c -o glibc
  510.  
  511.   Use ldd to verify the program was linked with glibc2, and not your old
  512.   libc:
  513.  
  514.         % ldd glibc
  515.         libc.so.6 => /lib/libc.so.6 (0x4000e000)
  516.         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
  517.  
  518.   If this compiles and generates "hello world!" when run, the installa¡
  519.   tion was successful.
  520.  
  521.   6.  Compiling with the non-primary libc
  522.  
  523.   There are times you will want to use an alternate library to compile
  524.   your programs with.  This section explains how to accomplish this,
  525.   using the directories and installation names used in the examples in
  526.   the previous two sections.  Remember to change the names to fit your
  527.   setup.
  528.  
  529.   6.1.  A warning when using non-primary libcs
  530.  
  531.   Before compiling any programs which is used in the system boot
  532.   process, remember that if the program is dynamically linked and is
  533.   used before the non-root partitions are mounted, all linked libraries
  534.   must be on the root partition.  Following the installation process in
  535.   the previous section for installing glibc as your primary C library,
  536.   the old libc is left in /lib, which will be on your root partition.
  537.   This means all of your programs will still work during booting.
  538.   However, if /usr is on a different partition and you install glibc as
  539.   a test library in /usr/i486-linuxglibc2, any new programs you compile
  540.   with glibc will not work until your /usr partition is mounted.
  541.  
  542.   6.2.  Compiling programs with a test glibc
  543.  
  544.   To compile a program with a test-install glibc, you need to reset the
  545.   include paths to point to the glibc includes.  Specifying "-nostdinc"
  546.   will negate the normal paths, and "-I/usr/i486-linuxglibc2/include"
  547.   will point to the glibc includes.  You will also need to specify the
  548.   gcc includes, which are found in /usr/lib/gcc-
  549.   lib/i486-linuxglibc2/2.7.2.2/include (assuming you installed the test
  550.   lib in i486-linuxglibc2 with gcc version 2.7.2.2).
  551.  
  552.   To link a program with a test-install glibc, you need to specify the
  553.   gcc setup.  This is done by using the option "-b i486-linuxglibc2".
  554.  
  555.   For most programs, you can specify these new options by adding them to
  556.   the CFLAGS and LDFLAGS makefile options:
  557.  
  558.         CFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -b i486-linuxglibc2
  559.         LDFLAGS = -b i486-linuxglibc2
  560.  
  561.   If you are using a configure script, define the CFLAGS and LDFLAGS
  562.   shell variables (by using env/setenv for csh/tcsh, or set/export for
  563.   sh/bash/etc) before running configure.  The makefiles generated by
  564.   this should contain the proper CFLAGS and LDFLAGS.  Not all configure
  565.   scripts will pick up the variables, so you should check after running
  566.   configure and edit the makefiles by hand if necessary.
  567.  
  568.   If the programs you are compiling only call gcc (and not cpp or
  569.   binutils directly), you can use the following script to save having to
  570.   specify all of the options each time:
  571.  
  572.         #!/bin/bash
  573.         /usr/bin/gcc -b i486-linuxglibc2 -nostdinc \
  574.                      -I/usr/i486-linuxglibc2/include \
  575.                      -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include "$@"
  576.  
  577.   You can then use this script instead of "gcc" when compiling.
  578.  
  579.   6.3.  Compiling programs with libc 5 when glibc is primary library
  580.  
  581.   To compile a program with your old libraries when you have installed
  582.   glibc as your main library, you need to reset the include paths to the
  583.   old includes.  Specifying "-nostdinc" will negate the normal paths,
  584.   and "-I/usr/i486-linuxlibc5/include" will point to the glibc includes.
  585.   You must also specify "-I/usr/lib/gcc-
  586.   lib/i486-linuxlibc5/2.7.2.2/include" to include the gcc specific
  587.   includes.  Remember to adjust these paths based on the what you named
  588.   the new directories and your gcc version.
  589.  
  590.   To link a program with your old libc, you need to specify the gcc
  591.   setup.  This is done by using the option "-b i486-linuxlibc5".
  592.  
  593.   For most programs, you can specify these new options by appending them
  594.   to the CFLAGS and LDFLAGS makefile options:
  595.  
  596.         CFLAGS = -nostdinc -I/usr/i486-linuxlibc5/include -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include -b i486-linuxlibc5
  597.         LDFLAGS = -b i486-linuxlibc5
  598.  
  599.   If you are using a configure script, define the CFLAGS and LDFLAGS
  600.   shell variables (by using env/setenv for csh/tcsh, or set/export for
  601.   sh/bash/etc) before running configure.  The makefiles generated by
  602.   this should contain the proper CFLAGS and LDFLAGS.  Not all configure
  603.   scripts will pick up the variables, so you should check after running
  604.   configure and edit the makefiles by hand if necessary.
  605.  
  606.   If the programs you are compiling only call gcc (and not cpp or
  607.   binutils directly), you can use the following script to save having to
  608.   specify all of the options each time:
  609.  
  610.         #!/bin/bash
  611.         /usr/bin/gcc -b i486-linuxlibc5 -nostdinc \
  612.                      -I/usr/i486-linuxlibc5/include \
  613.                      -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include "$@"
  614.  
  615.   You can then use this script instead of "gcc" when compiling.
  616.  
  617.   7.  Compiling C++ programs
  618.  
  619.   Libg++ uses parts of the math library, so is link to libm.  Since your
  620.   existing libg++ will be compiled with your old library, you will have
  621.   to recompile libg++ with glibc or get a binary copy.  The latest
  622.   source for libg++ along with a binary linked with glibc (for x86) can
  623.   be found at <ftp://ftp.yggdrasil.com/private/hjl/>.
  624.  
  625.   7.1.  Installing libg++ for a test glibc install
  626.  
  627.   If you have installed glibc as a test library, you need to install the
  628.   files into the directory you installed glibc into (such as
  629.   /usr/i486-linuxglibc2 for the example in the previous sections).  If
  630.   you are installing from the binary package (which i would recommend,
  631.   since i never had any luck compiling libg++ this way), you need to
  632.   extract the files into a temporary directory and move all the usr/lib/
  633.   files into the <install directory>/lib/ directory, the usr/include/
  634.   files into the <install directory>/include/ directory (remember to
  635.   delete your include/g++ link first!), and the usr/bin/ files into the
  636.   <install directory>/bin/ directory.
  637.  
  638.   7.2.  Installing libg++ for a primary glibc install
  639.  
  640.   If you have installed glibc as the primary library, you first need to
  641.   move your old libg++ files into your old libc directory if you still
  642.   want to be able to compile g++ programs with your old libc.  Probably
  643.   the easiest way to do this is by installing a new copy of the libg++
  644.   compiled with libc 5 as in the previous section, and then installing
  645.   the glibc version normally.
  646.  
  647.   7.3.  Compiling C++ programs with the non-primary libc
  648.  
  649.   If you are trying to compile a C++ program with a non-primary libc,
  650.   you will need to include the g++ include dir, which in the examples
  651.   above would be /usr/i486-linuxglibc2/include/g++ for a test glibc
  652.   install or /usr/i486-linuxlibc5/include/g++ for a primary glibc
  653.   install.  This can usually be done by appending the CXXFLAGS variable:
  654.         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
  655.  
  656.   8.  Reporting bugs
  657.  
  658.   Once you've found a bug, make sure it's really a bug. A good way to do
  659.   this is to see if the GNU C library behaves the same way some other C
  660.   library does. If so, probably you are wrong and the libraries are
  661.   right (but not necessarily). If not, one of the libraries is probably
  662.   wrong.
  663.  
  664.   Next, go to  <http://www-gnats.gnu.ai.mit.edu:8080/cgi-
  665.   bin/wwwgnats.pl>, and look through the bug database.  Check here to
  666.   verify the problem has not already be reported.
  667.  
  668.   Once you're sure you've found a new bug, try to narrow it down to the
  669.   smallest test case that reproduces the problem. In the case of a C
  670.   library, you really only need to narrow it down to one library
  671.   function call, if possible.  This should not be too difficult.
  672.  
  673.   The final step when you have a simple test case is to report the bug.
  674.   When reporting a bug, send your test case, the results you got, the
  675.   results you expected, what you think the problem might be (if you've
  676.   thought of anything), your system type, and the version of the GNU C
  677.   library which you are using.  Also include the files `config.status'
  678.   and `config.make' which are created by running `configure`; they will
  679.   be in whatever directory was current when you ran `configure'.
  680.  
  681.   All bug reports for the GNU C library should be sent using the
  682.   glibcbug shell script which comes with the GNU libc to
  683.   <bugs@gnu.ai.mit.edu>, or submitted through the GNATS web interface at
  684.   <http://www-gnats.gnu.ai.mit.edu:8080/cgi-bin/wwwgnats.pl>.
  685.  
  686.   Suggestions and questions should be sent to the mailing list at <bugs-
  687.   glibc@prep.ai.mit.edu>.  If you don't read the gnewsgroup
  688.   gnu.bug.glibc, you can subscribe to the list by asking  <bug-glibc-
  689.   request@prep.ai.mit.edu>.
  690.  
  691.   Please DO NOT send bug report for the GNU C library to <bug-
  692.   gcc@prep.ai.mit.edu>.  That list is for bug reports for GNU CC.  GNU
  693.   CC and the GNU C library are separate entities maintained by separate
  694.   people.
  695.  
  696.   9.  Sample specs file
  697.  
  698.   Included here is a sample 'specs' file for glibc 2 which is used by
  699.   gcc for compiling and linking.  It should be found in the directory
  700.   /usr/lib/gcc-lib/<new system dir>/<gcc version>.  If you are running
  701.   an x86 system, you probably can copy this section to the file exactly.
  702.  
  703.    *asm:
  704.    %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
  705.  
  706.    *asm_final:
  707.    %{pipe:-}
  708.  
  709.    *cpp:
  710.    %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
  711.  
  712.    *cc1:
  713.    %{profile:-p}
  714.  
  715.    *cc1plus:
  716.  
  717.    *endfile:
  718.    %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
  719.  
  720.    *link:
  721.    -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:       %{rdynamic:-export-dynamic}     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}
  722.  
  723.    *lib:
  724.    %{!shared: %{pthread:-lpthread}        %{profile:-lc_p} %{!profile: -lc}}
  725.  
  726.    *libgcc:
  727.    -lgcc
  728.  
  729.    *startfile:
  730.    %{!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}
  731.  
  732.    *switches_need_spaces:
  733.  
  734.    *signed_char:
  735.    %{funsigned-char:-D__CHAR_UNSIGNED__}
  736.  
  737.    *predefines:
  738.    -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
  739.  
  740.    *cross_compile:
  741.    0
  742.  
  743.    *multilib:
  744.    . ;
  745.  
  746.   10.  Miscellanea
  747.  
  748.   10.1.  Further information
  749.  
  750.   10.1.1.  Web Pages
  751.  
  752.   ╖  FSF's GNU C Library Home Page
  753.      <http://www.gnu.org/software/libc/libc.html>
  754.  
  755.   ╖  Using GNU Libc 2 with Linux <http://www.imaxx.net/~thrytis/glibc/>
  756.  
  757.   10.1.2.  Newgroups
  758.  
  759.   ╖  comp.os.linux.development.system
  760.  
  761.   ╖  comp.os.linux.development.apps
  762.  
  763.   ╖  linux.dev.kernel
  764.  
  765.   ╖  gnu.bugs.glibc
  766.  
  767.   10.2.  Credits
  768.  
  769.   Most of this information was stolen from the GNU Libc web page
  770.   <http://www.gnu.org/software/libc/libc.html> and from Ulrich Drepper's
  771.   <drepper@gnu.ai.mit.edu> glibc 2 announcement and his comments.
  772.  
  773.   The following people have provided information and feedback for this
  774.   document:
  775.  
  776.   ╖  Mark Brown <M.A.Brown-4@sms.ed.ac.uk>
  777.  
  778.   ╖  Aron Griffis <agriffis@coat.com>
  779.  
  780.   ╖  Ryan McGuire <rmcguire@freenet.columbus.oh.us>
  781.  
  782.   ╖  Shaya Potter <spotter@capaccess.org>
  783.  
  784.   ╖  Les Schaffer <godzilla@futuris.net>
  785.  
  786.   ╖  Andy Sewell <puck@pookhill.demon.co.uk>
  787.  
  788.   ╖  Stephane <sr@adb.fr>
  789.  
  790.   ╖  Jan Vandenbos <jan@imaxx.net>
  791.  
  792.   10.3.  Feedback
  793.  
  794.   Besides writing this HOWTO, maintaining the glibc 2 for Linux
  795.   <http://www.imaxx.net/~thrytis/glibc> page, and using it on my
  796.   machine, I have nothing to do with the glibc project.  I am far from
  797.   knowledgeable on this topic.  I welcome any feedback, corrections, or
  798.   suggestions you have to offer.  Please send them to thrytis@imaxx.net
  799.   <mailto:thrytis@imaxx.net>.
  800.  
  801.