📄 0541-0543.html
字号:
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Motif Programming</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=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=26 //-->
<!-- PAGES=0529-0544 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0537-0540.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0544-0544.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-541"><P>Page 541</P></A>
<P>How about nearly a two-megabyte difference? If you're going to build Motif clients, you'll
want to use the shared libraries (usually a default) because, as you can see, you'd quickly run out
of room on your hard drive.
</P>
<H3><A NAME="ch26_ 18">
The UIL Compiler
</A></H3>
<P>Although I don't have enough room to discuss the User Interface Language (UIL), if you
want to quickly and easily build your program's interface, you might want to learn this
language, and its compiler, uil. For details on using the compiler and language, read the
uil and UIL man pages. A number of the Motif demonstration programs use UIL, so you can read
source code examples.
</P>
<P>
There are also many commercial graphical interface builders that enable you to draw and
design your interface, test it, and then, with the click of a button, write out the Motif
source code. See the Motif FAQ for more information. (Pointers for the FAQ are at the end of
this chapter in the section "For More Information.")
</P>
<H3><A NAME="ch26_ 19">
Tutorials and Examples
</A></H3>
<P>If you're serious about learning Motif programming, you'll need to have several good
books and lots of program examples. If you want a basic introduction, you can also try some on
the online tutorials or peruse code examples. Try one of these sites:
</P>
<UL>
<LI> <a href="http://www.cen.com/mw3/code.html">http://www.cen.com/mw3/code.html</A>
Contains a number of useful links to Motif programming code examples, lectures,
and tutorials.
<LI> <a href="http://www.iftech.com">http://www.iftech.com</A>
Contains a Motif programming tutorial you might find helpful when getting started.
<LI> ftp://ftp.vse.cz
Look under
/pub/linux/freeware_for_motif/motif-tutor for a copy of Jan
Borchers' xmtutor, an interactive tutorial on Motif
programming.
</UL>
<H3><A NAME="ch26_ 20">
Using imake and xmkmf
</A></H3>
<P>You should be familiar with Todd Brunhoff's
imake utility and Jim Fulton's xmkmf command if you've created or built programs for the X Window System. Like the
make command, these commands help you save time, prevent errors, and organize your programming tasks by
automating the building process.
</P>
<P>imake, a C preprocessor interface to make, uses configuration files found under
the /usr/X11R6/lib/X11/config directory. These files include
linux.cf, lnxLib.rules, lnxLib.tmpl, lnxdoc.rules, and
lnxdoc.tmpl.
</P>
<A NAME="PAGENUM-542"><P>Page 542</P></A>
<P>The xmkmf command, which creates a Makefile from an
Imakefile, is a simple shell script that runs
imake, telling it where to find the specifics about your system and which
command-line parameters need to be passed to your compiler, assembler, linker, and even man-page
formatter. Note that you should never run imake by itself; always use the
xmkmf script instead.
</P>
<P>Typically, after unpacking the source for an X or Motif program, you use the
xmkmf command and then the make command to build your program. Another of the reasons many
programmers use imake is to ensure portability. Assuming the
imake file is written properly, the xmkmf command will work on nearly any UNIX system, and that includes Linux.
</P>
<P>imake works by reading an Imakefile. In turn, the
Imakefile contains directions for the cpp compiler preprocessor, whose output is then fed back into
imake, which in turn, generates the Makefile for your program. The magic of
imake is that it simplifies the job of creating
Makefiles for every possible computer or operating system your program could be built on or run under.
</P>
<P>For example, here's a simple Imakefile for our sample program,
skeleton.c:
</P>
<!-- CODE //-->
<PRE> INCLUDES = -I.
DEPLIBS = XmClientDepLibs
LOCAL_LIBRARIES = XmClientLibs
SRCS= skeleton.c
OBJS= skeleton.o
PROGRAMS = skel
NormalLibraryObjectRule()
MComplexProgramTarget(skeleton,$(LOCAL_LIBRARIES),$(SYSLIBS))
</PRE>
<!-- END CODE //-->
<P>To use this listing, type it in your favorite text editor (such as
nedit) and save the text as Imakefile. Then, use the two commands
</P>
<!-- CODE SNIP //-->
<PRE># xmkmf
# make
</PRE>
<!-- END CODE SNIP //-->
<P>to build the program. This will also save you a lot of time if you use the
edit-compile-run-edit cycle of programming, as you won't have to retype the compiler command line shown
earlier in this chapter (# gcc -o skel skeleton.c -L/usr/X11R6/lib -lXm -lXpm -lXt -lXext
-lX11).
</P>
<H3><A NAME="ch26_ 21">
LessTif—An Alternative Motif Clone
</A></H3>
<P>Much of the success of Linux is a direct result of the generosity of the thousands of
programmers who chose to distribute their software either for free or under the GNU Public
License. Motif, as you already know, is not freeware, nor is it distributed under the GPL. As Red
Hat Linux users, we're spoiled by the ability to examine program source or make changes as we
see fit.
</P>
<P>Want the source to Motif for your computer's operating system? It will cost you $17,000
at the time of this writing. If you're interested in building a distribution of Motif for Linux,
you can get the price list by browsing to <a href="http://www.opengroup.org/tech/desktop/ordering/">http://www.opengroup.org/tech/desktop/ordering/</A>
motif.price.list.htm.
</P>
<A NAME="PAGENUM-543"><P>Page 543</P></A>
<P>For those of us who like source code or want to build Motif-compliant clients without
paying for a distribution, there's an alternative: LessTif. This is a Motif clone, designed to be
compatible with Motif 1.2. Distributed under the terms of the GNU GPL, LessTif currently
builds 26 different Motif clients (probably many more by the time you read this).
</P>
<P>You can find a copy of the current LessTif distribution for Linux
at <a href="http://www.lesstif.org.">http://www.lesstif.org.</A>
</P>
<P>The current distribution doesn't require that you use
imake or xmkmf, and it comes with shared and static libraries. If you're a real Motif hacker and you're interested in the internals of
graphical interface construction and widget programming, you should read the details of how LessTif
is constructed. You can get a free copy of Harold Albrecht's book,
Inside LessTif, at <a href="http://www.igpm.rwth-aachen.de/~albrecht/hungry.html">http://www.igpm.rwth-aachen.de/~albrecht/hungry.html</A>
.
</P>
<H3><A NAME="ch26_ 22">
For More Information
</A></H3>
<P>If you're interested in finding answers to common questions about Motif, read Ken Lee's
Motif FAQ, which is posted regularly to the newsgroup
comp.windows.x.motif. Without a doubt, this is the best source of information on getting started with Motif, but it won't replace a
good book on Motif programming. You can find the FAQ on the newsgroup, or at
ftp://ftp.rahul.net/pub/kenton/faqs/Motif-FAQ.
</P>
<P>An HTML version can be found at
<a href="http://www.rahul.net/kenton/faqs/motif-faq.html.">http://www.rahul.net/kenton/faqs/Motif-FAQ.html.</A>
</P>
<P>For information on how to use imake, read Paul DuBois'
Software Portability with imake from O'Reilly & Associates.
</P>
<P>For Motif 1.2 programming and reference material, read Dan Heller and Paula M.
Ferguson's Motif Programming Manual and Paula M. Ferguson and David Brennan's
Motif Reference Manual, both from O'Reilly & Associates.
</P>
<P>For the latest news about Motif or CDE, check The Open Group's site at
<a href="http://www.opengroup.org.">http://www.opengroup.org.</A>
</P>
<P>For the latest information, installation, or programming errata about Red Hat's Motif
distribution, see <a href="http://www.redhat.com.">http://www.redhat.com.</A>
</P>
<P>For the latest binaries of LessTif, programming hints, and a list of Motif 1.2-compatible
functions and Motif clients that build under the latest LessTif distribution, see
<a href="http://www.lesstif.org.">http://www.lesstif.org.</A>
</P>
<P>For official information on Motif 1.2 from OSF, the following titles (from Prentice-Hall)
might help:
</P>
<UL>
<LI> OSF/Motif Programmers Guide
<LI> OSF/Motif Programmers Reference Manual
<LI> OSF/Motif Style Guide
</UL>
<P><CENTER>
<a href="0537-0540.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0544-0544.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -