920-923.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 98 行
HTML
98 行
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Working with the Kernel</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=57//-->
<!--PAGES=920-923//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="918-920.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="923-926.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading4"></A><FONT COLOR="#000077">Adding Drivers to the Kernel</FONT></H3>
<P>You may want to link in new device drivers or special software to the kernel without going through the upgrade process of the kernel itself. This is often necessary when a new device such as a multiport board or an optical drive is added to the system and should be loaded during the boot process. Alternatively, you may be adding special security software that must be linked into the kernel.
</P>
<P>The add-in kernel software usually has installation instructions provided, but the general process is to locate the source in a directory that can be found by the kernel recompilation process (such as <TT>/usr/src</TT>). To instruct the <TT>make</TT> utility to add the new code to the kernel, modifications are often needed to the <TT>Makefile</TT>. These may be performed manually or by an installation script. Some software has its own <TT>Makefile</TT> supplied for this reason.</P>
<P>Then, the kernel recompilation is begun with the new software added in to the load. The process is the same as shown in the section above, with the kernel installed in the boot location or set by LILO. Typically, the entire process takes about 10 minutes and is quite trouble-free, unless the vendor of the kernel modification did a sloppy job. Make sure that the source code provided for the modification will work with your version of the Linux kernel by reading any text files that accompany the code as well as the software compatibility files included with most distributions of Linux.</P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Upgrading Libraries</FONT></H3>
<P>Most of the software on a Linux system is set to use shared libraries (a set of subroutines used by many programs). When you see the message
</P>
<!-- CODE SNIP //-->
<PRE>
Incompatible library version
</PRE>
<!-- END CODE SNIP //-->
<P>display after you have performed an upgrade to the system and you try to execute a utility, it means that the libraries have been updated and need to be recompiled. Most libraries are backward-compatible, so existing software should work properly even after a library upgrade.
</P>
<P>Library upgrades are less frequent than kernel upgrades, and you can find them in the same places. Usually there are documents that guide you to the latest version of a library or there may be a file explaining which libraries are necessary with new versions of the operating system kernel.</P>
<P>Most library upgrades are gzipped <TT>tar</TT> files, and the process for unpacking them is the same as for kernel source code except the target directories are usually <TT>/lib</TT>, <TT>/usr/lib</TT> and <TT>/usr/include</TT>. Usually, any files that have the extension <TT>.a</TT> or <TT>.aa</TT> go in the <TT>/usr/lib</TT> directory. Shared library image files, which have the format <TT>libc.so</TT>. version are installed into <TT>/lib</TT>.</P>
<P>You may have to change symbolic links within the file system to point to the latest version of the library. For example, if you are running library version <TT>libc.so.4.4.1</TT> and upgraded to <TT>libc.so.4.4.2</TT>, you must alter the symbolic link set in <TT>/lib</TT> to this file. The command is</P>
<!-- CODE SNIP //-->
<PRE>
ln -sf /lib/libc/so/4/4/1 /lib/libc.so.4
</PRE>
<!-- END CODE SNIP //-->
<P>where the last name in the link command is the name of the current library file in <TT>/lib</TT>. Your library name may be different, so check the directory and release or installation notes first.</P>
<P>You will also have to change the symbolic link for the file <TT>libm.so.</TT> version in the same manner. Do not delete the symbolic links, because all programs that depend on the shared library (including <TT>ls</TT>) will be unable to function.</P>
<H3><A NAME="Heading6"></A><FONT COLOR="#000077">The Linux C Compiler</FONT></H3>
<P>Linux uses a C compiler for every compilation of the kernel (and most utilities, too). The C compiler that is available for all versions of Linux is the GNU C compiler, abbreviated <TT>gcc</TT>. This compiler was created under the Free Software Foundation’s programming license and is therefore freely distributable.</P>
<P>The GNU C Compiler that is packaged with the Slackware Linux distribution is a fully functional ANSI C-compatible compiler. If you are familiar with a C compiler on a different operating system or hardware platform you will be able to learn <TT>gcc</TT> very quickly.</P>
<P>The GCC compiler is invoked by passing it a number of options and one or more filenames. The basic syntax for <TT>gcc</TT> is</P>
<!-- CODE SNIP //-->
<PRE>
gcc [options] [filenames]
</PRE>
<!-- END CODE SNIP //-->
<P>The operations specified by the command line options will be performed on each of the files on the command line. There are well over 100 compiler options that can be passed to <TT>gcc</TT>. You will probably never use most of these options, but some of them you will use on a regular basis.</P>
<P>Many of the <TT>gcc</TT> options consist of more than one character. For this reason, you must specify each option with its own hyphen. You cannot group options after a single hyphen as you can with most Linux commands. For example, the following two commands are not the same:</P>
<!-- CODE SNIP //-->
<PRE>
gcc -p -g test.c
gcc -pg test.c
</PRE>
<!-- END CODE SNIP //-->
<P>The first command tells <TT>gcc</TT> to compile <TT>test.c</TT> with profile information (<TT>-p</TT>) and also to store debugging information with the executable (<TT>-c</TT>). The second command simply tells <TT>gcc</TT> to compile <TT>test.c</TT> with profile information for the <TT>gprof</TT> command (<TT>-pc</TT>).</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="918-920.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="923-926.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?