📄 460-464.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Configuration and Installation:Programming in Linux</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=1558285660//-->
<!--TITLE=Linux Configuration and Installation//-->
<!--AUTHOR=Patrick Volkerding//-->
<!--AUTHOR=Kevin Reichard//-->
<!--AUTHOR=Eric Foster//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=10//-->
<!--PAGES=460-464//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="457-460.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="464-467.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>As you compile Linux freeware, you’ll notice that there are a lot of conventions with <B>make</B> and <B>Makefile</B>s. For example, most <B>Makefile</B>s contain a target called <B>all</B>, which rebuilds the entire program when you execute:</P>
<!-- CODE SNIP //-->
<PRE>
$ make all
</PRE>
<!-- END CODE SNIP //-->
<P>For this command to work, the <B>Makefile</B> must have a target named <I>all</I> that tells <B>make</B> what to do to rebuild everything. In addition, most <B>Makefile</B>s contain a clean target that removes all <I>.o</I> files and other files created by the compiler, and an install target that copies the built executable file to an installation directory, such as <B>/usr/local/bin</B>.</P>
<P><FONT SIZE="+1"><B>Imake</B></FONT></P>
<P>In addition to <B>make</B>, there’s another tool called <B>imake</B>. <B>Imake</B> is used to generate <B>Makefile</B>s on a variety of systems. <B>Imake</B> uses an <B>Imakefile</B> for its rules. These rules then help generate a <B>Makefile</B>, which is used by <B>make</B> to build the program. Sound convoluted? It is. The main reason <B>imake</B> exists is because of radically different system configurations, especially where the X Window System is concerned.</P>
<P>You’ll find <B>imake</B> especially popular with programs for X Window. The problem with X is that there are so many options that every UNIX platform is configured slightly differently. There’s simply no way you could write a portable <B>Makefile</B> that could work on all such platforms. <B>Imake</B> uses an <B>Imakefile</B> and configuration files that are local to your system. Together, the <B>Imakefile</B> and the local configuration files generate a <B>Makefile</B> that should work on your system. (In addition to <B>imake</B>, there’s an even handier package called GNU <B>configure</B>. Unfortunately, <B>imake</B> is very common among X Window programs, and <B>configure</B> is not.)</P>
<P>If you need to compile programs for the X Window System and you see an <B>Imakefile</B>, here’s what you should do. First, run the <B>xmkmf</B> shell script. This script is merely a simple front end to <B>imake</B>:</P>
<!-- CODE SNIP //-->
<PRE>
$ xmkmf
mv Makefile Makefile.bak
imake -DUseInstalled -I/usr/lib/X11/config
</PRE>
<!-- END CODE SNIP //-->
<P>These commands should make a backup of any <B>Makefile</B> you have (to <B>Makefile.bak</B>) and then create a new <B>Makefile</B> based on the commands in an <B>Imakefile</B>.</P>
<P><B>Imake</B> isn’t easy to grasp, so if you have problems with <B>imake</B>, check with your system administrator or look up <B>imake</B> in a book on the X Window System (such as <I>Using X</I>, MIS:Press, 1992; see Appendix A for a list of books on using the X Window System).</P>
<P><FONT SIZE="+1"><B>Debuggers</B></FONT></P>
<P>Because Linux remains firmly in the GNU program-development world, it provides the <B>gdb</B> debugger, as well as the X Window front end, <B>xxgdb</B>, as shown in Figure 10.1.</P>
<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/10-01.jpg',589,639 )"><IMG SRC="images/10-01t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/10-01.jpg',589,639)"><FONT COLOR="#000077"><B>Figure 10.1</B></FONT></A> The <B>xxgdb</B> debugger.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077">X Window Tools</FONT></H4>
<P>If you’re developing X Window applications, a few extra utilities may help. The <B>xman</B> program (mentioned in Chapter 5) provides a graphical front end and nice formatting for UNIX online-manual pages.</P>
<P>For critical X programs, you’ll find <B>xcmap</B> very useful. This simple X application displays the current colormap. For color-intensive X applications, this can help you track down obscure X problems.</P>
<P>Similarly, the <B>xev</B> application helps you see what events the keyboard keys are really sending to the X server.</P>
<P>For selecting fonts, <B>xfd</B> and <B>xfontsel</B> both help you choose a good-looking font for your applications.</P>
<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077">Parsers and Lexers</FONT></H4>
<P>If you’re used to building your own parsers, you’ll like the GNU <B>bison</B> (a port of UNIX <B>yacc</B>—Yet Another Compiler Compiler) and <B>flex</B> (a fast <B>lex</B>). Linux even includes <B>flex++</B> for developing C++ scanners.</P>
<H4 ALIGN="LEFT"><A NAME="Heading16"></A><FONT COLOR="#000077">Other Tools</FONT></H4>
<P>We list some more useful tools for programmers in Table 10.5.
</P>
<TABLE WIDTH="100%"><CAPTION><B>Table 10.5</B> More Useful Programming Tools
<TR>
<TH WIDTH="30%" ALIGN="LEFT">Tool
<TH WIDTH="70%" ALIGN="LEFT">Usage
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TD WIDTH="30%"><B>ar</B>
<TD WIDTH="70%">Collects object files into libraries
<TR>
<TD><B>diff</B>
<TD>Compares differences between files
<TR>
<TD VALIGN="TOP"><B>gprof</B>
<TD>Gathers timing statistics about your programs for performance tuning
<TR>
<TD VALIGN="TOP"><B>hexdump</B>
<TD>Displays ASCII, decimal, hexadecimal, or octal dump of a file
<TR>
<TD><B>objdump</B>
<TD>Display information on object files
<TR>
<TD><B>ranlib</B>
<TD>Generates an index in an <B>ar</B>-created archive (library)
<TR>
<TD><B>rcs</B>
<TD>Source code Revision Control System
<TR>
<TD><B>strace</B>
<TD>Displays system calls from your program
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>There’s even a tool called <B>ansi2knr</B> that converts ANSI C to old-style Kernighan and Ritchie-style C (without function prototypes). With Linux, you don’t really need this, as <B>gcc</B> fully supports ANSI C.</P>
<P>There are more tools than what we listed in Table 10.5. Chances are that just about every UNIX freeware tool is available on Linux.</P>
<H3><A NAME="Heading17"></A><FONT COLOR="#000077">Other Programming Languages</FONT></H3>
<P>C is by and large the programming <I>lingua franca</I> on UNIX and Linux, with C++ (an object-oriented extension to C) fast gaining in popularity. In addition to these languages, Linux provides a host of other opportunities to program.</P>
<P>First, the GNU C compiler also supports the Objective-C extension to the C programming language. Objective-C is very popular under the Nextstep environment. The GNU C compiler also supports a Fortran 77 front end called <B>g77</B>.</P>
<P>For artificial intelligence fans, there’s Common Lisp (under the name <B>clisp</B>). Additional programming languages include Ada and Pascal.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>None of the programming tools or languages get installed on a Slackware Linux system unless you specifically ask for them by running the <B>setup</B> program.<HR></FONT>
</BLOCKQUOTE>
<H4 ALIGN="LEFT"><A NAME="Heading18"></A><FONT COLOR="#000077">Java the Hut</FONT></H4>
<P>One of the hottest new languages, especially for World Wide Web applications, is Sun’s Java. Java programs get compiled to a portable set of byte codes, which can execute on any system that supports the Java Virtual Machine. There’s a version of Java for Linux; on the second CD-ROM: the Java Development Kit, or JDK.. As of this writing, this software is in a very preliminary format, but it’s worth checking out.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="457-460.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="464-467.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -