%% $Header: /cvsroot/lcdp/lpic/general-linux-1/slides/gl1.102.4.slides.tex,v 1.4 2003/05/30 05:09:04 waratah Exp $

\input{gl1.slide-header.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----10->|-----20->|-----30->|-----40->|-----50->|-----60->|-----70->|-----80->
\begin{slide} %================================================================
\begin{center} \LARGE \textsf{-- General Linux 1 -- \\
Manage Shared Libraries}
\LARGE \textsf{[3] } \\[2mm]
\large  \textsf{(Linux Professional Institute Certification)}\\[1mm]

\normalsize\end{center}

\footnote{Copyright \copyright\ 2002 Geoffrey Robertson. Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation---either version 2 of the License or (at your option) any later version.}
 
\scriptsize
\begin{verbatim} 
   .~.         from IBM developerWorks tutorial
   /V\         geoffrey robertson        
  // \\        geoffrey@zip.com.au
  @._.@ 
\end{verbatim} 
\tiny
\begin{verbatim}
$Id: gl1.102.4.slides.tex,v 1.4 2003/05/30 05:09:04 waratah Exp $ 
\end{verbatim} 
\normalsize  
\vfill \end{slide} %-----------------------------------------------------------
%----10->|-----20->|-----30->|-----40->|-----50->|-----60->|-----70->|-----80->

%==============================================================================
\begin{slide} %ghr
  \listofslides
\vfill \end{slide}
%------------------------------------------------------------------------------

%=============================================================================
%=============================================================================
\begin{slide} %ghr
\slideheading{(2.2) 102 Installation \& Package Mgt. [24]}
  \begin{description}
  \item[2.102.1] Design hard disk layout [2]
  \item[2.102.2] Install a boot manager [3]
  \item[2.102.3] Make and install programs from source [5]
  \item[2.102.4] {\bf \underline{Manage Shared Libraries [3]}}
  \item[2.102.5] Use Debian package management [5]
  \item[2.102.6] Use Red Hat Package Manager (RPM) [6] 
  \end{description}
\vfill \end{slide} %-----------------------------------------------------------
 
%=============================================================================
\begin{slide}{} %ghr
\Slidecontents
\vfill \end{slide} %-----------------------------------------------------------
 
% =============================================================================
% =============================================================================
 \begin{slide} %ghr
 \slideheading{Manage Shared Libraries}
 \slidesubheading{Objective} 

 Candidates should be able to determine the shared libraries that
 executable programs depend on and install them when necessary.
 Candidates should be able to state where system libraries are kept.

 \vfill \end{slide} %-----------------------------------------------------------
 
%=============================================================================
\begin{slide} %ghr
\Slideheading{Manage Shared Libraries}
\slidesubheading{Key files, terms, and utilities}
\begin{alltt}
  
ldd
ldconfig

/etc/ld.so.conf 
LD_LIBRARY_PATH
\end{alltt}

\vfill \end{slide} %-----------------------------------------------------------

%=============================================================================
\begin{slide} %ghr
\Slideheading{Manage Shared Libraries}
\slidesubheading{Resources of interest}

\begin{description}
\item[Shared-Library HOWTO]: 
\begin{alltt}
http://linuxdocs.org/HOWTOs/Program-Library-HOWTO/
\end{alltt}
\item[LPI certification 102 exam prep, Part 1]: 
\begin{alltt}
http://ibm.com/developerWorks 
\end{alltt}
\end{description}

\vfill \end{slide} %-----------------------------------------------------------
 
%=============================================================================
\begin{slide}{} %ghr
\Slidecontents
\vfill \end{slide} %-----------------------------------------------------------

% =============================================================================
% =============================================================================
 \begin{slide}{}
 \slideheading{Introducing shared libraries} 
\slidesubheading{} 

On Linux systems there are two fundamentally different types of Linux
executable programs.
   \begin{description}

\overlay{1}
\item[statically linked executables]:\\
  contain all the functions that they need to execute
 
\overlay{2}
\item[dynamically linked executables]:\\
  require libraries of functions
   \end{description}

\vfill \end{slide} %-----------------------------------------------------------

%=============================================================================
%=============================================================================
\begin{slide}{}
\slideheading{Static vs. Dynamic Executables}
\slidesubheading{\texttt{ldd}}

We can use the \texttt{ldd} command to determine if a particular executable
 program is static:
 \begin{alltt}
 \cmd{ldd /sbin/sln} 
        not a dynamic executable
 \end{alltt}

\overlay{1}
 \slidesubheading{Relative Size}
 \begin{alltt}
 \cmd{ls -l /bin/ln /sbin/sln} 
 -rwxr-xr-x 1 root root 23000  Jan 14 00:36 /bin/ln 
 -rwxr-xr-x 1 root root 381072 Jan 14 00:31 /sbin/sln
 \end{alltt}

\vfill \end{slide} %-----------------------------------------------------------

%=============================================================================
%=============================================================================
\begin{slide}{}
\slideheading{Dynamically Linked Dependencies}

\begin{itemize}
\item To view a list of all the shared libraries upon which ln depends, use
 the ldd command:

\begin{alltt}
\cmd{ldd /bin/ln}
libc.so.6 => /lib/libc.so.6 (0x40021000) 
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
\end{alltt}

\overlay{1} 
 \item As a rule, dynamically linked programs are much smaller than their
 statically-linked equivalents.

\overlay{2} 
 \item \texttt{/lib/ld-linux.so.2} is the loader
 \end{itemize}
\vfill \end{slide} %-----------------------------------------------------------
 
%=============================================================================
%=============================================================================
\begin{slide}{}
 \slideheading{The dynamic loader} 
   \begin{itemize}
   \item The dynamic loader takes care of loading the shared libraries that
   dynamically linked executables need in order to run.

\overlay{1}
\item The dynamic loader finds shared libraries thanks to two files --
  \texttt{/etc/ld.so.conf} and \texttt{/etc/ld.so.cache}. 

\overlay{2}
\item The contents of  \texttt{/etc/ld.so.conf}:

\begin{alltt}
cat /etc/ld.so.conf 
/usr/X11R6/lib 
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3 
/usr/lib/mozilla 
/usr/lib/qt-x11-2.3.1/lib 
/usr/local/lib  
\end{alltt}
\end{itemize}
\vfill \end{slide} %-----------------------------------------------------------

%=============================================================================
%=============================================================================
\begin{slide}{}
\slideheading{ld.so.cache}

 Before the dynamic loader can "see" this information, it must be
 converted into an \texttt{ld.so.cache} file. 

 This is done by running the ldconfig command:
\begin{alltt}
\cmd{ldconfig}  
\end{alltt}

 When \texttt{ldconfig} completes, you now have an up-to-date
 \texttt{/etc/ld.so.cache} file that reflects any changes you've made
 to \texttt{/etc/ld.so.conf}.

\vfill \end{slide} %-----------------------------------------------------------

%=============================================================================
%=============================================================================
\begin{slide}{}
\slideheading{\texttt{ldconfig} tips}

To view all the shared libraries that \texttt{ldconfig} can "see," type:
\begin{alltt} 
\cmd{ldconfig -p | less}
\end{alltt}

 Sometimes, you'll want to tell the dynamic loader to try to use shared
 libraries in a specific directory before trying any of your
 \texttt{/etc/ld.so.conf} paths. 

 For older application requiring older libraries.

\vfill \end{slide} %-----------------------------------------------------------

%=============================================================================
%=============================================================================
\begin{slide}{}
\slideheading{\texttt{LD\_LIBRARY\_PATH}}
\begin{itemize}
\item To instruct the dynamic loader to check a certain directory
   first, set the\texttt{ LD\_LIBRARY\_PATH} variable to the
   directories that you would like searched.  

   \overlay{1}
 \item Separate multiple paths
   using colons; for example:
   
\begin{alltt}
\rootcmd{export LD\_LIBRARY\_PATH="/usr/lib/old:/opt/lib"}
\end{alltt}

\overlay{2}
\item After \texttt{LD\_LIBRARY\_PATH} has been exported, any executables
 started from the current shell will use libraries in
 \texttt{/usr/lib/old} or \texttt{/opt/lib} if possible, falling back
 to the directories specified in \texttt{/etc/ld.so.conf} if some
 shared library dependencies are still unsatisfied.
 \end{itemize}

\vfill \end{slide} %-----------------------------------------------------------

%==============================================================================
%==============================================================================
\begin{slide}{}
\slideheading{Summary}

\begin{itemize}
\item 
\slidesubheading{ldd}

\overlay{1}
\item 
Lists the required libraries

\overlay{2}
\item 
\slidesubheading{ld.so.conf}
\overlay{3}
\item 
list of library paths

\overlay{4}
\item 
\slidesubheading{\texttt{ldconfig}}
\overlay{5}
\item 
Updates \texttt{/etc/ls.so.cache} from \texttt{ld.so.conf}

\overlay{6}
\item 
\slidesubheading{\texttt{LD\_LIBRARY\_PATH}}
\overlay{7}
\item 
Holds library path for current shell
\end{itemize}

\vfill \end{slide} %-----------------------------------------------------------


%=============================================================================
\begin{slide}{} %ghr
  \heading{The End}
  \Slidecontents
\vfill \end{slide} %-----------------------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%==============================================================================
%==============================================================================
\begin{slide}{}
\slideheading{}


\vfill \end{slide} %-----------------------------------------------------------

=============================================================================
\begin{slide}{}

\end{slide} %------------------------------------------------------------------

