Added a few comments here and there
[linux_from_scratch.git] / FAQ-OBSOLETE / how-to-compile.xml
blob1004cc015a1e686babf9f68dfce778eef28096b9
1 <qandaentry id="how-to-compile">
2 <question><para>How do i compile a package?</para></question>
3 <answer>
4 <para>Here's an example when everything works:
5 <screen>tar xvjf foo-0.0.tar.bz2
6 cd foo-0.0
7 ./configure --prefix=/usr
8 make
9 make install
10 <emphasis role="strong">cd ..
11 rm -rf foo-0.0</emphasis>
12 </screen></para>
13 <para>
14 Deleting the source at the end is important.
15 The source is only useful for reinstalling without recompiling
16 because "make clean" and friends are not reliable.
17 See the next example for what to do if "./configure" or "make" fail.
18 </para>
19 <para>The only exception to deleting the source is the Linux Kernel.
20 Most people keep their kernel source so they don't have to reconfigure
21 it from scratch if they need to make a small change.
22 If a large change is needed, like changing processor type,
23 it may be necessary to delete and re-extract even with the kernel.
24 </para>
25 <para>And here's an example for if something (in this case configure) fails:
26 <screen>tar xvjf foo-0.0.tar.bz2
27 cd foo-0.0
28 ./configure --prefix=/usr
32 *** configure: error: foo requires libess 4.2 or greater
33 please install libess and rerun configure.
34 <emphasis role="strong">cd ..
35 rm -rf foo-0.0</emphasis>
36 tar xvjf libess-4.2.tar.bz2
37 cd libess-4.2
38 ./configure --prefix=/usr
39 make
40 make install
41 <emphasis role="strong">cd ..
42 rm -rf libess-4.2</emphasis>
43 tar xvjf foo-0.0.tar.bz2
44 cd foo-0.0
45 ./configure --prefix=/usr
46 make
47 make install
48 <emphasis role="strong">cd ..
49 rm -rf foo-0.0</emphasis>
50 </screen></para>
51 <para>Ed. Note: The name of the fictional libess above follows
52 libiberty (from glibc, AFAIK) and libofat.
53 The reason comes from the gcc flag, -l, for linking a library when compiling.
54 For instance,
55 <screen>gcc -o foo foo.c -lm
56 </screen>
57 would link the "m" (math) library with the executable foo.
58 So, for the libraries above, the command looks like:
59 <screen>gcc -o foo foo.c -liberty -lowfat -less
60 </screen></para>
61 <para>Bonus points if you caught the reference to
62 The Hitchhiker's Guide to the Galaxy, by Douglas Adams in the example.
63 </para></answer>
64 </qandaentry>