/usr/share/doc/gccintro/gccintro/Finding-dynamically-linked-libraries.html is in gccintro 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 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 68 69 70 71 | <html lang="en">
<head>
<title>Finding dynamically linked libraries - An Introduction to GCC</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="An Introduction to GCC">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Examining-compiled-files.html#Examining-compiled-files" title="Examining compiled files">
<link rel="prev" href="Examining-the-symbol-table.html#Examining-the-symbol-table" title="Examining the symbol table">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Finding-dynamically-linked-libraries"></a>
<p>
Previous: <a rel="previous" accesskey="p" href="Examining-the-symbol-table.html#Examining-the-symbol-table">Examining the symbol table</a>,
Up: <a rel="up" accesskey="u" href="Examining-compiled-files.html#Examining-compiled-files">Examining compiled files</a>
<hr>
</div>
<h3 class="section">13.3 Finding dynamically linked libraries</h3>
<p><a name="index-dynamically-linked-libraries_002c-examining-with-_0040code_007bldd_007d-795"></a><a name="index-shared-libraries_002c-examining-with-_0040code_007bldd_007d-796"></a><a name="index-g_t_0040code_007bldd_007d_002c-dynamical-loader-797"></a><a name="index-dependencies_002c-of-shared-libraries-798"></a><a name="index-shared-libraries_002c-dependencies-799"></a><a name="index-libraries_002c-finding-shared-library-dependencies-800"></a>When a program has been compiled using shared libraries it needs to load
those libraries dynamically at run-time in order to call external
functions. The command <samp><span class="command">ldd</span></samp> examines an executable and
displays a list of the shared libraries that it needs. These libraries
are referred to as the shared library <dfn>dependencies</dfn> of the
executable.
<p>For example, the following commands demonstrate how to find the shared
library dependencies of the <dfn>Hello World</dfn> program:
<pre class="example"> $ gcc -Wall hello.c
$ ldd a.out
libc.so.6 => /lib/libc.so.6 (0x40020000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
</pre>
<p class="noindent">The output shows that the <dfn>Hello World</dfn> program depends on the C
library <code>libc</code> (shared library version 6) and the dynamic loader
library <code>ld-linux</code> (shared library version 2).
<p>If the program uses external libraries, such as the math library, these
are also displayed. For example, the <code>calc</code> program (which uses
the <code>sqrt</code> function) generates the following output:
<pre class="example"> $ gcc -Wall calc.c -lm -o calc
$ ldd calc
libm.so.6 => /lib/libm.so.6 (0x40020000)
libc.so.6 => /lib/libc.so.6 (0x40041000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
</pre>
<p class="noindent">The first line shows that this program depends on the math library
<code>libm</code> (shared library version 6), in addition to the C library and
dynamic loader library.
<p>The <code>ldd</code> command can also be used to examine shared libraries
themselves, in order to follow a chain of shared library dependencies.
</body></html>
|