1491 lines
25 KiB
HTML
1491 lines
25 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Software Development</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="Troubleshooting"
|
|
HREF="troubleshooting.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Solutions to Common Problems"
|
|
HREF="common-problems.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="troubleshooting.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="common-problems.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="development"
|
|
></A
|
|
>13. Software Development</H1
|
|
><DIV
|
|
CLASS="qandaset"
|
|
><DL
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#how-do-i-compile-programs"
|
|
>How Do I Compile Programs?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#port-xxx-to-linux"
|
|
>How Do I Port <EM
|
|
>XXX</EM
|
|
> to Linux?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#code-or-compiler-for-486-on-386"
|
|
>Can I Use Code or a Compiler Compiled for a 486 on a 386?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#what-does-gcc-o6-do"
|
|
>What Does <TT
|
|
CLASS="literal"
|
|
>gcc -O6</TT
|
|
> Do?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#errors-when-i-try-to-compile"
|
|
>What Do I Do About Errors Trying to Compile the Kernel?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#make-shared-library"
|
|
>How Do I Make a Shared Library?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#executables-are-very-large"
|
|
>Why Are My Programs So Large?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#math-lib-errors"
|
|
>How To Prevent Errors when Linking Programs with Math Functions</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#program-xyz-under-linux"
|
|
>How To Program <EM
|
|
>XYZ</EM
|
|
> Under Linux</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#upgrade-recompile-kernel"
|
|
>How To Upgrade/Recompile a Kernel</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#What-is-a-gz-file-tgz"
|
|
>What Is a <TT
|
|
CLASS="literal"
|
|
>.gz</TT
|
|
> File? And a <TT
|
|
CLASS="literal"
|
|
>.tgz</TT
|
|
>? And <TT
|
|
CLASS="literal"
|
|
>.bz2</TT
|
|
>? And... ?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#linux-h-and-asm-h"
|
|
>Where Are <TT
|
|
CLASS="filename"
|
|
>linux/*.h</TT
|
|
> and <TT
|
|
CLASS="filename"
|
|
>asm/*.h</TT
|
|
>?</A
|
|
></DT
|
|
><DT
|
|
>Q: <A
|
|
HREF="development.html#configure-emacs-with-default"
|
|
>Configuring <SPAN
|
|
CLASS="application"
|
|
>Emacs</SPAN
|
|
>' Default Settings</A
|
|
></DT
|
|
></DL
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="how-do-i-compile-programs"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>How Do I Compile Programs?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Most Linux software is written in C and compiled
|
|
with the GNU C compiler. GCC is a part of every Linux distribution. The
|
|
latest compiler version, documentation, and patches are on
|
|
<A
|
|
HREF="ftp://ftp.gnu.org/pub/gnu/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://ftp.gnu.org/pub/gnu/</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
>Programs that are written in C++ must be compiled with the GNU G++ compiler,
|
|
which is also included in Linux distributions and available from the same
|
|
place as GCC.
|
|
</P
|
|
><P
|
|
>To build version 2.0.x kernels, you will need
|
|
GCC version 2.7.2.x, approximately. Trying to build an early Linux kernel
|
|
with a different compiler, like GCC 2.8.x, EGCS, or PGCC, may cause problems
|
|
because of GCC related code dependencies. Kernel versions 2.2, 2.4, and the 2.5 development kernels should compile correctly with more recent compilers.
|
|
</P
|
|
><P
|
|
>Information on the EGCS compiler is at <A
|
|
HREF="http://www.gnu.org/software/gcc/gcc.html"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>http://www.gnu.org/software/gcc/gcc.html</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
>Note that at this time, the kernel developers are not answering bug
|
|
requests for earlier kernels, but instead are concentrating on developing
|
|
2.5.x version kernels and maintaining 2.2.x and 2.4.x version kernels.
|
|
</P
|
|
><P
|
|
>[J.H.M. Dassen, Axel Boldt]
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="port-xxx-to-linux"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>How Do I Port <EM
|
|
>XXX</EM
|
|
> to Linux?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>In general, *nix programs need very little porting. Simply follow the installation instructions.
|
|
If you don't know and don't know how to find out the answers to some of the
|
|
questions asked during the installation procedure, you can guess, but this
|
|
tends to produce buggy programs. In this case, you're probably better off
|
|
asking someone else to do the port.
|
|
</P
|
|
><P
|
|
>If you have a BSD-ish program, you should try using <B
|
|
CLASS="command"
|
|
>-I/usr/include/bsd</B
|
|
>
|
|
and <B
|
|
CLASS="command"
|
|
>-lbsd</B
|
|
> on the appropriate parts of the compilation lines.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="code-or-compiler-for-486-on-386"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>Can I Use Code or a Compiler Compiled for a 486 on a 386?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Yes, unless it's the kernel.
|
|
</P
|
|
><P
|
|
>The <B
|
|
CLASS="command"
|
|
>-m486</B
|
|
> option to <SPAN
|
|
CLASS="application"
|
|
>GCC</SPAN
|
|
>,
|
|
which is used to compile binaries for x486
|
|
machines, merely changes certain optimizations. This makes for slightly
|
|
larger binaries that run somewhat faster on a 486. They still work fine on a
|
|
386, though, with a small performance hit.
|
|
</P
|
|
><P
|
|
>However, from version 1.3.35 the kernel uses 486 or Pentium-specific instructions if
|
|
configured for a 486 or Pentium, thus making it unusable on a 386.
|
|
</P
|
|
><P
|
|
><SPAN
|
|
CLASS="application"
|
|
>GCC</SPAN
|
|
> can be configured for a 386 or 486; the
|
|
only difference is that configuring it for a 386 makes
|
|
<B
|
|
CLASS="command"
|
|
>-m386</B
|
|
> the default and configuring for a 486 makes
|
|
<B
|
|
CLASS="command"
|
|
>-m486</B
|
|
> the default. In either case, these can be overridden
|
|
on a per-compilation basis or by editing <TT
|
|
CLASS="filename"
|
|
>/usr/lib/gcc-lib/i*-linux/</TT
|
|
>
|
|
<EM
|
|
>n.n.n</EM
|
|
><TT
|
|
CLASS="filename"
|
|
>/specs</TT
|
|
>.
|
|
</P
|
|
><P
|
|
>There is an alpha version of <SPAN
|
|
CLASS="application"
|
|
>GCC</SPAN
|
|
> that knows how to do
|
|
optimization well for the 586, but it is quite unreliable, especially at high
|
|
optimization settings. The Pentium GCC can be found on
|
|
<A
|
|
HREF="ftp://tsx-11.mit.edu/pub/linux/ALPHA/pentium-gcc/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://tsx-11.mit.edu/pub/linux/ALPHA/pentium-gcc/</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
>The ordinary 486 GCC supposedly produces better code for the
|
|
Pentium using the <B
|
|
CLASS="command"
|
|
>-m386</B
|
|
>, or at least slightly smaller.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="what-does-gcc-o6-do"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>What Does <TT
|
|
CLASS="literal"
|
|
>gcc -O6</TT
|
|
> Do?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Currently, the same as <B
|
|
CLASS="command"
|
|
>-O2</B
|
|
> (<SPAN
|
|
CLASS="application"
|
|
>GCC</SPAN
|
|
> 2.5) or
|
|
<B
|
|
CLASS="command"
|
|
>-O3</B
|
|
> (<SPAN
|
|
CLASS="application"
|
|
>GCC</SPAN
|
|
> 2.6, 2.7). Any number
|
|
greater than that does the same thing. The <TT
|
|
CLASS="filename"
|
|
>Makefile</TT
|
|
>s of
|
|
newer kernels use <B
|
|
CLASS="command"
|
|
>-O2</B
|
|
>, and you should probably do the
|
|
same.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="errors-when-i-try-to-compile"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>What Do I Do About Errors Trying to Compile the Kernel?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>See the previous question regarding the header files.
|
|
</P
|
|
><P
|
|
>Remember that when you apply a patch to the kernel, you must use the <TT
|
|
CLASS="literal"
|
|
>-p0</TT
|
|
> or
|
|
<TT
|
|
CLASS="literal"
|
|
>-p1</TT
|
|
> option: otherwise, the patch may be misapplied.
|
|
See the patch manual page for details.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>ld: unrecognized option -qmagic</TT
|
|
> means that you should get a newer
|
|
linker, from <A
|
|
HREF="ftp://tsx-11.mit.edu/pub/linux/packages/GCC/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://tsx-11.mit.edu/pub/linux/packages/GCC/</I
|
|
></A
|
|
>, in
|
|
the file <TT
|
|
CLASS="filename"
|
|
>binutils-2.8.1.0.1.bin.tar.gz</TT
|
|
>.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="make-shared-library"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>How Do I Make a Shared Library?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>For <SPAN
|
|
CLASS="acronym"
|
|
>ELF</SPAN
|
|
>,
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> $ gcc -fPIC -c *.c
|
|
$ gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 *.o</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>For <TT
|
|
CLASS="filename"
|
|
>a.out</TT
|
|
>, get <TT
|
|
CLASS="filename"
|
|
>tools-</TT
|
|
><EM
|
|
>n.nn</EM
|
|
><TT
|
|
CLASS="filename"
|
|
>.tar.gz</TT
|
|
>
|
|
from <TT
|
|
CLASS="filename"
|
|
>tsx-11.mit.edu/pub/linux/packages/GCC/src/</TT
|
|
>. It
|
|
comes with documentation that will tell you what to do. Note that
|
|
<TT
|
|
CLASS="filename"
|
|
>a.out</TT
|
|
> shared libraries are a very tricky business.
|
|
Consider upgrading your libraries to <SPAN
|
|
CLASS="acronym"
|
|
>ELF</SPAN
|
|
> shared libraries.
|
|
See the <I
|
|
CLASS="citetitle"
|
|
>ELF HOWTO</I
|
|
>, at
|
|
<A
|
|
HREF="ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/</I
|
|
></A
|
|
>.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="executables-are-very-large"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>Why Are My Programs So Large?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>With an <SPAN
|
|
CLASS="acronym"
|
|
>ELF</SPAN
|
|
> compiler (<A
|
|
HREF="system-libraries.html#about-elf-glibc"
|
|
><I
|
|
>What's All This about ELF? glibc?</I
|
|
></A
|
|
>),
|
|
the most common
|
|
cause of large executables is the lack of an appropriate .so library link for
|
|
one of the libraries you're using. There should be a link like
|
|
<TT
|
|
CLASS="filename"
|
|
>libc.so</TT
|
|
> for every library like <TT
|
|
CLASS="filename"
|
|
>libc.so.5.2.18</TT
|
|
>.
|
|
</P
|
|
><P
|
|
>With an <TT
|
|
CLASS="filename"
|
|
>a.out</TT
|
|
> compiler the most common cause of large
|
|
executables is the <B
|
|
CLASS="command"
|
|
>-g</B
|
|
> linker (compiler) flag. This
|
|
produces (as well as debugging information in the output file) a program
|
|
which is statically linkedone which includes a copy of the C library instead
|
|
of a dynamically linked copy.
|
|
</P
|
|
><P
|
|
>Other things worth investigating
|
|
are <B
|
|
CLASS="command"
|
|
>-O</B
|
|
> and <B
|
|
CLASS="command"
|
|
>-O2</B
|
|
>, which enable
|
|
optimization (check the GCC documentation), and -s (or the strip command)
|
|
which strip the symbol information from the resulting binary (making
|
|
debugging totally impossible).
|
|
</P
|
|
><P
|
|
>You may wish to use -N on very
|
|
small executables (less than 8K with the -N), but you shouldn't do this
|
|
unless you understand its performance implications, and definitely never with
|
|
daemons.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="math-lib-errors"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>How To Prevent Errors when Linking Programs with Math Functions</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Older run-time libraries included the math library in the C run-time library.
|
|
It was not necessary to specify the math library separately when compiling.
|
|
If the compiler generates a message like this when linking a program that uses math functions:
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> /tmp/ccDUQM4J.o: In function "main":
|
|
/tmp/ccDUQM4J.o(.text+0x19): undefined reference to "sqrt"
|
|
collect2: ld returned 1 exit status </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>You need use the <TT
|
|
CLASS="literal"
|
|
>-lm</TT
|
|
> option with GCC to link with the math libraries:
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> # gcc -o program program.c -lm </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>Make sure also to use the statement <TT
|
|
CLASS="literal"
|
|
>#include
|
|
<math.h></TT
|
|
> in the source file.
|
|
</P
|
|
><P
|
|
>[Florian Schmidt]
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="program-xyz-under-linux"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>How To Program <EM
|
|
>XYZ</EM
|
|
> Under Linux</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Read the manuals, or a good book on Unix and the manual pages (type <TT
|
|
CLASS="literal"
|
|
>man man</TT
|
|
>).
|
|
There is a lot of GNU Info documentation, which is often more useful as a
|
|
tutorial. Run Emacs and type
|
|
<B
|
|
CLASS="keycap"
|
|
>F1</B
|
|
>-<B
|
|
CLASS="keycap"
|
|
>i</B
|
|
>, or type
|
|
<B
|
|
CLASS="command"
|
|
>info info</B
|
|
> if you don't have or don't like Emacs. Note that
|
|
the Emacs libc node may not exactly describe the latest Linux libc, or GNU
|
|
glibc2. But the GNU project and LDP are always looking for volunteers to
|
|
upgrade their library documentation.
|
|
</P
|
|
><P
|
|
>Anyway, between the
|
|
existing Texinfo documentation, and the manual pages in sections 2 and 3,
|
|
should provide enough information to get started.
|
|
</P
|
|
><P
|
|
>As with all free software, the best tutorial is the source code itself.
|
|
</P
|
|
><P
|
|
>The latest release of the Linux manual pages, a collection of useful GNU Info
|
|
documentation, and various other information related to programming Linux,
|
|
can be found on <TT
|
|
CLASS="filename"
|
|
>metalab.unc.edu/pub/Linux/docs/man-pages/</TT
|
|
>.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="upgrade-recompile-kernel"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>How To Upgrade/Recompile a Kernel</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>See the <I
|
|
CLASS="citetitle"
|
|
>Kernel HOWTO</I
|
|
> or the <TT
|
|
CLASS="filename"
|
|
>README</TT
|
|
> files which come with
|
|
the kernel release on <A
|
|
HREF="ftp://ftp.cs.helsinki.fi/pub/Software/Linux/Kernel/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://ftp.cs.helsinki.fi/pub/Software/Linux/Kernel/</I
|
|
></A
|
|
> and
|
|
mirrors.
|
|
See <A
|
|
HREF="linux-distributions.html#get-linux-material-by-ftp"
|
|
><I
|
|
>Where Are the Linux FTP Archives?</I
|
|
></A
|
|
>.
|
|
You may already have a version of the
|
|
kernel source code installed on your system, but if it is part of a standard
|
|
distribution it is likely to be somewhat out of date (this is not a problem
|
|
if you only want a custom configured kernel, but it probably is if you need
|
|
to upgrade.)
|
|
</P
|
|
><P
|
|
>With newer kernels you can (and should) make all
|
|
of the following targets. Don't forget that you can specify multiple targets
|
|
with one command.
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> $ make clean dep install modules modules_install </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>Also remember to update the module
|
|
dependencies.
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> $ depmod -a </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>This command can be run automatically at boot time. On Debian/GNU Linux systems,
|
|
the command is part of the <TT
|
|
CLASS="filename"
|
|
>/etc/init.d/modutils</TT
|
|
> script,
|
|
and can be linked appropriately in the <TT
|
|
CLASS="filename"
|
|
>/etc/rc</TT
|
|
><EM
|
|
>x</EM
|
|
><TT
|
|
CLASS="filename"
|
|
>.d/</TT
|
|
>
|
|
directories. For more information on <B
|
|
CLASS="command"
|
|
>depmod</B
|
|
>, see the
|
|
manual page.
|
|
</P
|
|
><P
|
|
>Make sure you are using the most recent version
|
|
of the modutils utilities, as well as all other supporting packages. Refer to
|
|
the file <TT
|
|
CLASS="filename"
|
|
>Documentation/Changes</TT
|
|
> in the kernel source tree
|
|
for specifics, and be sure to consult the <TT
|
|
CLASS="filename"
|
|
>README</TT
|
|
> file in
|
|
the <SPAN
|
|
CLASS="application"
|
|
>modutils</SPAN
|
|
> package.
|
|
</P
|
|
><P
|
|
>Remember that to make the new kernel boot you must run <B
|
|
CLASS="command"
|
|
>lilo</B
|
|
> after
|
|
copying the kernel into your root partition. The Makefile in some kernels
|
|
have a special <TT
|
|
CLASS="literal"
|
|
>zlilo</TT
|
|
> target for this; try:
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> $ make zlilo </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>On current systems, however, you can simply copy the <TT
|
|
CLASS="filename"
|
|
>zImage</TT
|
|
> or
|
|
<TT
|
|
CLASS="filename"
|
|
>bzImage</TT
|
|
> file (in <TT
|
|
CLASS="filename"
|
|
>arch/i386/boot/</TT
|
|
> to
|
|
the <TT
|
|
CLASS="filename"
|
|
>/boot/</TT
|
|
> directory on the root file system, or to a
|
|
floppy using the <B
|
|
CLASS="command"
|
|
>dd</B
|
|
> command. Refer also to the question,
|
|
How do I get LILO to boot the kernel image?
|
|
</P
|
|
><P
|
|
>Kernel version numbers with an odd minor version (ie, 1.1.x, 1.3.x) are the testing
|
|
releases; stable production kernels have even minor versions (1.0.x, 1.2.x).
|
|
If you want to try the testing kernels you should probably subscribe to the
|
|
linux-kernel mailing list.
|
|
See <A
|
|
HREF="online-resources.html#what-mailing-lists-are-there"
|
|
><I
|
|
>What Mailing Lists Are There?</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
>The Web site <A
|
|
HREF="http://www.kernelnotes.org/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>http://www.kernelnotes.org/</I
|
|
></A
|
|
> has lots of
|
|
information and links to other sites that provide information about Linux
|
|
kernel updates.
|
|
</P
|
|
><P
|
|
>Also refer to the answers for,
|
|
<A
|
|
HREF="troubleshooting.html#upgraded-kernel-pcmcia-doesnt-work"
|
|
><I
|
|
>Why Doesn't My PCMCIA Card Work after Upgrading the Kernel?</I
|
|
></A
|
|
> and
|
|
<A
|
|
HREF="booting.html#lilo-boot-kernel-image"
|
|
><I
|
|
>How Do I Get LILO to Boot the Kernel Image?</I
|
|
></A
|
|
>.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Alternatively, on Debian GNU/Linux systems, get a kernel source package
|
|
from the Debian archive or from a Debian GNU/Linux CD. Then, follow the
|
|
directions in the <TT
|
|
CLASS="filename"
|
|
>README</TT
|
|
> file that is located in the <TT
|
|
CLASS="filename"
|
|
>kernel-package</TT
|
|
>
|
|
subdirectory.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="What-is-a-gz-file-tgz"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>What Is a <TT
|
|
CLASS="literal"
|
|
>.gz</TT
|
|
> File? And a <TT
|
|
CLASS="literal"
|
|
>.tgz</TT
|
|
>? And <TT
|
|
CLASS="literal"
|
|
>.bz2</TT
|
|
>? And... ?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
><TT
|
|
CLASS="literal"
|
|
>.gz</TT
|
|
> (and <TT
|
|
CLASS="literal"
|
|
>.z</TT
|
|
>) files are compressed using GNU
|
|
<B
|
|
CLASS="command"
|
|
>gzip</B
|
|
>. You need to use <B
|
|
CLASS="command"
|
|
>gunzip</B
|
|
> (which is
|
|
a symlink to the <B
|
|
CLASS="command"
|
|
>gzip</B
|
|
> command that comes with most Linux
|
|
installations) to unpack the file.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.taz</TT
|
|
>, <TT
|
|
CLASS="literal"
|
|
>.tar.Z</TT
|
|
>, and <TT
|
|
CLASS="literal"
|
|
>.tz</TT
|
|
> are
|
|
<EM
|
|
>tar</EM
|
|
> files (made with <B
|
|
CLASS="command"
|
|
>tar</B
|
|
>) and
|
|
compressed using <B
|
|
CLASS="command"
|
|
>compress</B
|
|
>. The standard *nix
|
|
<B
|
|
CLASS="command"
|
|
>compress</B
|
|
> is proprietary software, but free equivalents
|
|
like ncompress exist.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.tgz</TT
|
|
> (or <TT
|
|
CLASS="literal"
|
|
>.tpz</TT
|
|
>) is a tar file compressed with
|
|
<B
|
|
CLASS="command"
|
|
>gzip</B
|
|
>.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.bz2</TT
|
|
> is a file compressed by the more recently introduced (and efficient)
|
|
<B
|
|
CLASS="command"
|
|
>bzip2</B
|
|
>.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.lsm</TT
|
|
> is a <I
|
|
CLASS="citetitle"
|
|
>Linux Software Map</I
|
|
> entry, in the form of a short text
|
|
file. Details about the LSM project and the LSM itself are available in the
|
|
subdirectory on <A
|
|
HREF="ftp://metalab.unc.edu/pub/Linux/docs/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://metalab.unc.edu/pub/Linux/docs/</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.deb</TT
|
|
> is a Debian Binary Package - the binary package
|
|
format used by the Debian GNU/Linux distribution. It is manipulated using
|
|
<B
|
|
CLASS="command"
|
|
>dpkg</B
|
|
> and <B
|
|
CLASS="command"
|
|
>dpkg-deb</B
|
|
>
|
|
(available on Debian systems and from:
|
|
<A
|
|
HREF="http://ftp.debian.org/pool/main/d/dpkg/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>http://ftp.debian.org/pool/main/d/dpkg/</I
|
|
></A
|
|
>.
|
|
If you use anonymous FTP, connect to:
|
|
<A
|
|
HREF="ftp://ftp.debian.org/debian/pool/main/d/dpkg/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>ftp://ftp.debian.org/debian/pool/main/d/dpkg/</I
|
|
></A
|
|
>).
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.rpm</TT
|
|
> is a Red Hat RPM package, which is used in the Red
|
|
Hat and similar distributions.
|
|
</P
|
|
><P
|
|
><TT
|
|
CLASS="literal"
|
|
>.sit</TT
|
|
> is a compressed Macintosh archive made with StuffIt, a commercial program.
|
|
Aladdin Systems Inc., the manufacturer of StuffIt, has a free expander utility that
|
|
will uncompress these archives. You can download it at
|
|
<A
|
|
HREF="http://www.aladdinsys.com/expander/"
|
|
TARGET="_top"
|
|
><I
|
|
CLASS="citetitle"
|
|
>http://www.aladdinsys.com/expander/</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
>The <B
|
|
CLASS="command"
|
|
>file</B
|
|
> command can often tell you what a file is.
|
|
</P
|
|
><P
|
|
>If you find that <B
|
|
CLASS="command"
|
|
>gzip</B
|
|
> complains when you
|
|
try to uncompress a file, you probably downloaded it in ASCII mode by
|
|
mistake. You must download most things in binary mode:
|
|
<TT
|
|
CLASS="literal"
|
|
>get</TT
|
|
>, to download the file.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="linux-h-and-asm-h"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>Where Are <TT
|
|
CLASS="filename"
|
|
>linux/*.h</TT
|
|
> and <TT
|
|
CLASS="filename"
|
|
>asm/*.h</TT
|
|
>?</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>The files <TT
|
|
CLASS="filename"
|
|
>/usr/include/linux/</TT
|
|
> and <TT
|
|
CLASS="filename"
|
|
>/usr/include/asm/</TT
|
|
>
|
|
are often soft links to the
|
|
directories where the kernel headers are. They are usually under
|
|
<TT
|
|
CLASS="filename"
|
|
>/usr/src/kernel*/</TT
|
|
>.
|
|
</P
|
|
><P
|
|
>If you don't have the kernel sources, download them. Refer to the answer for
|
|
<A
|
|
HREF="development.html#upgrade-recompile-kernel"
|
|
><I
|
|
>How To Upgrade/Recompile a Kernel</I
|
|
></A
|
|
>.
|
|
</P
|
|
><P
|
|
>Then, use <B
|
|
CLASS="command"
|
|
>rm</B
|
|
> to remove any garbage, and
|
|
<B
|
|
CLASS="command"
|
|
>ln</B
|
|
> to create the links:
|
|
</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="screen"
|
|
> $ rm -rf /usr/include/linux /usr/include/asm
|
|
$ ln -sf /usr/src/linux/include/linux /usr/include/linux
|
|
$ ln -sf /usr/src/linux/include/asm-<architecture> /usr/include/asm</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><P
|
|
>The assembly language files reside in architecture-specific directories, so you need to link
|
|
<TT
|
|
CLASS="literal"
|
|
>/usr/src/include/asm</TT
|
|
> to
|
|
<TT
|
|
CLASS="literal"
|
|
>/usr/src/linux/include/asm-i386</TT
|
|
> on PC compatible systems,
|
|
to <TT
|
|
CLASS="literal"
|
|
>/usr/src/linux/include/asm-sparc</TT
|
|
> on Sun Sparc systems,
|
|
to <TT
|
|
CLASS="literal"
|
|
>/usr/src/linux/include/asm-ppc</TT
|
|
> on PPC systems, and so
|
|
on.
|
|
</P
|
|
><P
|
|
>You'll also find that you may need to do "make config" as
|
|
in a newly-unpacked kernel source tree, to create
|
|
<TT
|
|
CLASS="filename"
|
|
>linux/autoconf.h</TT
|
|
>.
|
|
</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="qandaentry"
|
|
><DIV
|
|
CLASS="question"
|
|
><P
|
|
><A
|
|
NAME="configure-emacs-with-default"
|
|
></A
|
|
><B
|
|
>Q: </B
|
|
>Configuring <SPAN
|
|
CLASS="application"
|
|
>Emacs</SPAN
|
|
>' Default Settings</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="answer"
|
|
><P
|
|
><B
|
|
>A: </B
|
|
>Create a file in your home directory named <TT
|
|
CLASS="filename"
|
|
>.emacs</TT
|
|
> with the Emacs
|
|
Lisp commands that you want to run every time Emacs starts up. You won't see
|
|
the file in the directory listing. (The leading '.' tells
|
|
<B
|
|
CLASS="command"
|
|
>ls</B
|
|
> not to display it, unless you use the
|
|
<TT
|
|
CLASS="literal"
|
|
>-a</TT
|
|
> command line switch with <B
|
|
CLASS="command"
|
|
>ls</B
|
|
>.)
|
|
</P
|
|
><P
|
|
>Any kind of Emacs Lisp statement will work in the
|
|
<TT
|
|
CLASS="filename"
|
|
>.emacs</TT
|
|
> file, including entire <TT
|
|
CLASS="literal"
|
|
>defuns</TT
|
|
>.
|
|
Emacs uses lisp variables and statements extensively, and many of the editing
|
|
functions are written in Emacs Lisp. For example, to enable word wrapping
|
|
whenever you edit a file that ends with <TT
|
|
CLASS="filename"
|
|
>.txt</TT
|
|
>, add the
|
|
following statement. This is from the Emacs Texinfo help document (
|
|
<B
|
|
CLASS="keycap"
|
|
>F1</B
|
|
>-<B
|
|
CLASS="keycap"
|
|
>i</B
|
|
>, then
|
|
<B
|
|
CLASS="keycap"
|
|
>m</B
|
|
> <TT
|
|
CLASS="literal"
|
|
>Emacs</TT
|
|
> <B
|
|
CLASS="keycap"
|
|
>Return</B
|
|
>):
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> (add-hook text-mode-hook
|
|
'(lambda () (auto-fill-mode1)))</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>This adds a statement that calls a
|
|
<EM
|
|
>hook</EM
|
|
> function whenever a text editing mode is entered
|
|
for that buffer. The value of <TT
|
|
CLASS="literal"
|
|
>text-mode-hook</TT
|
|
>, which is a
|
|
variable, to <TT
|
|
CLASS="literal"
|
|
>auto-fill-mode</TT
|
|
>, which is a function.
|
|
</P
|
|
><P
|
|
>If you want to turn off the menu bar at the top of each Emacs frame,
|
|
add this statement:
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> (menu-bar-mode -1)</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>And if you want to include an Emacs Lisp
|
|
program that someone has written, like <TT
|
|
CLASS="filename"
|
|
>msb.el</TT
|
|
> (an
|
|
enhanced, pop-up buffer menu), make sure the lisp file is in a directory
|
|
where Emacs can find it (usually it will be named Site-lisp), and add these
|
|
statements in the <TT
|
|
CLASS="filename"
|
|
>.emacs</TT
|
|
> file:
|
|
</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> (require 'msb)
|
|
(msb-mode 1) </PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><P
|
|
>Most tasks have several possible solutions in Emacs Lisp. Any task that can
|
|
be programmed in Emacs Lisp is valid in the <TT
|
|
CLASS="filename"
|
|
>.emacs</TT
|
|
> file.
|
|
For more information, consult the Texinfo documentation. There is also a FAQ
|
|
list for Emacs (refer to: What other FAQ's are there for Linux? ).
|
|
</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="troubleshooting.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="common-problems.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Troubleshooting</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Solutions to Common Problems</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |