old-www/FAQ/Linux-FAQ/system-libraries.html

597 lines
9.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>System Libraries</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="The Linux FAQ"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Partitions And Filesystems"
HREF="partitions.html"><LINK
REL="NEXT"
TITLE="Linux Distributions"
HREF="linux-distributions.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Linux FAQ</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="partitions.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="linux-distributions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="system-libraries"
></A
>6. System Libraries</H1
><DIV
CLASS="qandaset"
><DL
><DT
>Q: <A
HREF="system-libraries.html#linux-standards"
>Where Can I Find Linux System Specifications?</A
></DT
><DT
>Q: <A
HREF="system-libraries.html#ld-so-and-where-do-i-get-it"
>What Is <SPAN
CLASS="application"
>ld.so</SPAN
> and How Do I Get It?</A
></DT
><DT
>Q: <A
HREF="system-libraries.html#upgrade-libraries-withough-trashing"
>How Do I Upgrade the Libraries without Trashing the System?</A
></DT
><DT
>Q: <A
HREF="system-libraries.html#about-elf-glibc"
>What's All This about ELF? glibc?</A
></DT
></DL
><DIV
CLASS="qandaentry"
><DIV
CLASS="question"
><P
><A
NAME="linux-standards"
></A
><B
>Q: </B
>Where Can I Find Linux System Specifications?</P
></DIV
><DIV
CLASS="answer"
><P
><B
>A: </B
>As a start, look at the Linux Standards Base,
<A
HREF="http://www.linuxbase.org"
TARGET="_top"
><I
CLASS="citetitle"
>http://www.linuxbase.org</I
></A
>. The site contains
information about test software, file system organization, and shared library
naming conventions.
</P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><DIV
CLASS="question"
><P
><A
NAME="ld-so-and-where-do-i-get-it"
></A
><B
>Q: </B
>What Is <SPAN
CLASS="application"
>ld.so</SPAN
> and How Do I Get It?</P
></DIV
><DIV
CLASS="answer"
><P
><B
>A: </B
><SPAN
CLASS="application"
>ld.so</SPAN
> is the dynamic library loader. Each binary
using shared libraries used to have about 3K of start-up code to find and
load the shared libraries. Now that code has been put in a special shared
library, <TT
CLASS="filename"
>/lib/ld.so</TT
>, where all binaries can look for it,
so that it wastes less disk space, and can be upgraded more easily.
</P
><P
><TT
CLASS="literal"
>ld.so</TT
> can be obtained from
<A
HREF="http://tsx-11.mit.edu/pub/linux/packages/GCC/"
TARGET="_top"
><I
CLASS="citetitle"
>http://tsx-11.mit.edu/pub/linux/packages/GCC/</I
></A
> and
mirror sites. The latest version at the time of writing is
<TT
CLASS="filename"
>ld.so.1.9.5.tar.gz</TT
>.
</P
><P
><TT
CLASS="filename"
>/lib/ld-linux.so.1</TT
> is the same thing for ELF ("What's
all this about ELF? ") and comes in the same package as the
<TT
CLASS="filename"
>a.out</TT
> loader.
</P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><DIV
CLASS="question"
><P
><A
NAME="upgrade-libraries-withough-trashing"
></A
><B
>Q: </B
>How Do I Upgrade the Libraries without Trashing the System?</P
></DIV
><DIV
CLASS="answer"
><P
><B
>A: </B
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/warning.gif"
HSPACE="5"
ALT="Warning"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>You should always have a rescue disk set ready when you perform this
procedure, in the likely event that something goes wrong!</TD
></TR
></TABLE
></DIV
>
</P
><P
>This procedure is especially difficult if you're upgrading very old
libraries like <SPAN
CLASS="application"
>libc4</SPAN
>. But you should be able to
keep <SPAN
CLASS="application"
>libc4</SPAN
> on the same system with
<SPAN
CLASS="application"
>libc5</SPAN
> libraries for the programs that still need
them. The same holds true for upgrading from <SPAN
CLASS="application"
>libc5</SPAN
>
to the newer-yet <SPAN
CLASS="application"
>glibc2</SPAN
> libraries.
</P
><P
>The problem with upgrading dynamic libraries is that the moment you remove
the old libraries, the utilities that you need to upgrade to the new version
of the libraries don't work. There are ways around around this. One is to
temporarily place a spare copy of the run time libraries, which are in
<TT
CLASS="filename"
>/lib/</TT
>, in <TT
CLASS="filename"
>/usr/lib/</TT
>, or
<TT
CLASS="filename"
>/usr/local/lib/</TT
>, or another directory that is listed in the <TT
CLASS="filename"
>/etc/ld.so.conf</TT
> file.
</P
><P
>For example, when upgrading <SPAN
CLASS="application"
>libc5</SPAN
> libraries, the files in
<TT
CLASS="filename"
>/lib/</TT
> might look something like:
</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>libc.so.5 libc.so.5.4.33 libm.so.5 libm.so.5.0.9</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>These are the C libraries and the math libraries. Copy them to another
directory that is listed in <TT
CLASS="filename"
>/etc/ld.so.conf</TT
>, like
<TT
CLASS="filename"
>/usr/lib/</TT
>:
</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
> $ cp -df /lib/libc.so.5* /usr/lib/
$ cp -df /lib/libm.so.5* /usr/lib/
$ ldconfig</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>Be sure to run <B
CLASS="command"
>ldconfig</B
> to upgrade
the library configuration.
</P
><P
>The files <TT
CLASS="filename"
>libc.so.5</TT
> and <TT
CLASS="filename"
>libm.so.5</TT
> are
symbolic links to the actual library files. When you upgrade, the new links
will not be created if the old links are still there, unless you use the
<B
CLASS="command"
>-f</B
> flag with <B
CLASS="command"
>cp</B
>. The
<B
CLASS="command"
>-d</B
> flag to <B
CLASS="command"
>cp</B
> will copy the symbolic
link itself, and not the file it points to.
</P
><P
>If you need to overwrite the link to the library directly, use the <B
CLASS="command"
>-f</B
>
flag with <B
CLASS="command"
>ln</B
>.
</P
><P
>For example, to copy new libraries over the old ones, try this. Make a symbolic link to the new
libraries first, then copy both the libraries and the links to
<TT
CLASS="filename"
>/lib/</TT
>, with the following commands.
</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
> $ ln -sf ./libm.so.5.0.48 libm.so.5
$ ln -sf ./libc.so.5.0.48 libc.so.5
$ cp -df libm.so.5* /lib
$ cp -df libc.so.5* /lib</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>Again, remember to run <B
CLASS="command"
>ldconfig</B
> after you copy the
libraries.
</P
><P
>If you are satisfied that everything is working
correctly, you can remove the temporary copies of the old libraries from
<TT
CLASS="filename"
>/usr/lib/</TT
> or wherever you copied them.
</P
></DIV
></DIV
><DIV
CLASS="qandaentry"
><DIV
CLASS="question"
><P
><A
NAME="about-elf-glibc"
></A
><B
>Q: </B
>What's All This about ELF? glibc?</P
></DIV
><DIV
CLASS="answer"
><P
><B
>A: </B
>See the <I
CLASS="citetitle"
>ELF HOWTO</I
> by Daniel
Barlow. Note that this is not the file <TT
CLASS="filename"
>move-to-elf</TT
>,
which is a blow-by-blow account of how to upgrade to ELF manually.
</P
><P
>Linux has two different formats for executables, object files, and
object code libraries, known as, "ELF". (The old format is called
"a.out".) They have advantages, including better support for shared
libraries and dynamic linking.
</P
><P
>Both a.out and ELF binaries can coexist on a system.
However, they use different shared C libraries, both of
which have to be installed.
</P
><P
>If you want to find out whether your system can run ELF binaries, look in <TT
CLASS="filename"
>/lib</TT
> for a
file named, <TT
CLASS="filename"
>libc.so.5</TT
>. If it's there, you probably
have ELF libraries. If you want to know whether your installation actually is
ELF you can pick a representative program, like <B
CLASS="command"
>ls</B
>, and
run file on it:
</P
><P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
> -chiark:~&#62; file /bin/ls
/bin/ls: Linux/i386 impure executable (OMAGIC) - stripped
valour:~&#62; file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1, stripped </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>There is a patch to get 1.2.x to compile using the ELF compilers, and produce ELF core dumps, at
<A
HREF="ftp://tsx-11.mit.edu/pub/packages/GCC/"
TARGET="_top"
><I
CLASS="citetitle"
>ftp://tsx-11.mit.edu/pub/packages/GCC/</I
></A
>. You do not
need the patch merely to run ELF binaries. 1.3.x and later do not need the
patch at all.
</P
><P
>The GNU glibc2 libraries are essentially more
recent versions of ELF libraries that follow most of the same processes for
dynamic linking and loading. Upgrade information is contained in
<A
HREF="system-libraries.html#upgrade-libraries-withough-trashing"
><I
>How Do I Upgrade the Libraries without Trashing the System?</I
></A
>.
</P
></DIV
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="partitions.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="linux-distributions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Partitions And Filesystems</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Linux Distributions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>