3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Separate%20Objdir">Separate Objdir
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Config-Names.html#Config%20Names">Config Names
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"Installing-GDB.html#Installing%20GDB">Installing GDB
</a>
18 <h3 class=
"section">Compiling GDB in another directory
</h3>
20 <p>If you want to run GDB versions for several host or target machines,
21 you need a different
<code>gdb
</code> compiled for each combination of
22 host and target.
<code>configure
</code> is designed to make this easy by
23 allowing you to generate each configuration in a separate subdirectory,
24 rather than in the source directory. If your
<code>make
</code> program
25 handles the
<code>VPATH
</code> feature (
<small>GNU
</small> <code>make
</code> does), running
26 <code>make
</code> in each of these directories builds the
<code>gdb
</code>
27 program specified there.
29 <p>To build
<code>gdb
</code> in a separate directory, run
<code>configure
</code>
30 with the
<code>--srcdir
</code> option to specify where to find the source.
31 (You also need to specify a path to find
<code>configure
</code>
32 itself from your working directory. If the path to
<code>configure
</code>
33 would be the same as the argument to
<code>--srcdir
</code>, you can leave out
34 the
<code>--srcdir
</code> option; it is assumed.)
36 <p>For example, with version
5.2.1, you can build GDB in a
37 separate directory for a Sun
4 like this:
39 <pre class=
"example"> cd gdb-
5.2.1
42 ../gdb-
5.2.1/configure sun4
46 <p>When
<code>configure
</code> builds a configuration using a remote source
47 directory, it creates a tree for the binaries with the same structure
48 (and using the same names) as the tree under the source directory. In
49 the example, you'd find the Sun
4 library
<code>libiberty.a
</code> in the
50 directory
<code>gdb-sun4/libiberty
</code>, and GDB itself in
51 <code>gdb-sun4/gdb
</code>.
53 <p>One popular reason to build several GDB configurations in separate
54 directories is to configure GDB for cross-compiling (where
55 GDB runs on one machine--the
<dfn>host
</dfn>--while debugging
56 programs that run on another machine--the
<dfn>target
</dfn>).
57 You specify a cross-debugging target by
58 giving the
<code>--target=
</code><var>target
</var><code></code> option to
<code>configure
</code>.
60 <p>When you run
<code>make
</code> to build a program or library, you must run
61 it in a configured directory--whatever directory you were in when you
62 called
<code>configure
</code> (or one of its subdirectories).
64 <p>The
<code>Makefile
</code> that
<code>configure
</code> generates in each source
65 directory also runs recursively. If you type
<code>make
</code> in a source
66 directory such as
<code>gdb-
5.2.1</code> (or in a separate configured
67 directory configured with
<code>--srcdir=
</code><var>dirname
</var><code>/gdb-
5.2.1</code>), you
68 will build all the required libraries, and then build GDB.
70 <p>When you have multiple hosts or targets configured in separate
71 directories, you can run
<code>make
</code> on them in parallel (for example,
72 if they are NFS-mounted on each of the hosts); they will not interfere