📄 16-building programs.mht
字号:
From: <由 Windows Internet Explorer 7 保存>
Subject: Building Programs
Date: Thu, 15 May 2008 14:49:40 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_012F_01C8B69A.E7C44E80"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
This is a multi-part message in MIME format.
------=_NextPart_000_012F_01C8B69A.E7C44E80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://sourcenav.sourceforge.net/online-docs/userguide/progide.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><HEAD><TITLE>Building Programs</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3DISO-8859-1">
<META http-equiv=3DContent-Style-Type content=3Dtext/css>
<META content=3D"MSHTML 6.00.6000.16544" name=3DGENERATOR><LINK=20
href=3D"http://sourcenav.sourceforge.net/online-docs/cygnus2.css" =
type=3Dtext/css=20
charset=3DISO-8859-1 rel=3DSTYLESHEET></HEAD>
<BODY bgColor=3D#ffffff>
<DIV>
<TABLE class=3DTABLE cellPadding=3D1 width=3D100 align=3Dcenter =
border=3D0>
<TBODY>
<TR>
<TD align=3Dmiddle>
<P class=3DGotos><A=20
=
href=3D"http://sourcenav.sourceforge.net/online-docs/userguide/index_ug.h=
tml">Contents</A>=20
</P></TD>
<TD align=3Dmiddle>
<P class=3DGotos><A=20
=
href=3D"http://sourcenav.sourceforge.net/online-docs/userguide/debugger.h=
tml">Previous</A></P></TD>
<TD align=3Dmiddle>
<P class=3DGotos><A=20
=
href=3D"http://sourcenav.sourceforge.net/online-docs/userguide/elixcmdlin=
e.html">Next</A></P></TD></TR></TBODY></TABLE>
<HR align=3Dcenter>
</DIV>
<H1 class=3DChapterTitle><A name=3DpgfId-998205></A><A =
name=3D42744></A>Building=20
Programs
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-1.g=
if">=20
</DIV></H1>
<P class=3DBody><A name=3DpgfId-998209></A>Source-Navigator allows you =
to build=20
executable programs from the files in your project. Using =
Source-Navigator, you=20
can compile your code, navigate to any errors, link your code, and, with =
the=20
Insight debugger, set up a debugging session to debug your code.</P>
<H3 class=3DLabel><A name=3DpgfId-998216></A>Note</H3>
<P class=3DNote><A name=3DpgfId-998220></A>The compiler, <KBD =
class=3DCode>make</KBD>,=20
and the Insight debugger must be installed on your machine before using =
these=20
features.</P>
<P class=3DBody><A name=3DpgfId-1002352></A>At the end of this chapter, =
there is a=20
<A=20
href=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide.ht=
ml#tutorial">build=20
tutorial</A> for a command line-driven real estate trading game.</P>
<H2 class=3DHeading1><A name=3DpgfId-998221></A>The Building =
Process</H2>
<P class=3DBody><A name=3DpgfId-998222></A>The building process compiles =
and links=20
source files, such as libraries and executable files, to produce an =
output=20
binary file.</P>
<P class=3DFigureTitle><A name=3DpgfId-998226></A>Build Process</P>
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-2.g=
if">=20
</DIV>
<P class=3DBody><A name=3DpgfId-998227></A>There are four steps to =
building your=20
program:</P>
<UL>
<LI class=3DBullet>
<P class=3DBody><A name=3DpgfId-998228></A>editing your code, </P>
<LI class=3DBullet>
<P class=3DBody><A name=3DpgfId-998229></A>compiling your source into =
an=20
intermediate format, called object files, </P>
<LI class=3DBullet>
<P class=3DBody><A name=3DpgfId-998230></A>linking your object files =
together to=20
produce an executable application, and </P>
<LI class=3DBullet>
<P class=3DBody><A name=3DpgfId-998231></A>debugging your executable =
to find any=20
problems. </P></LI></UL>
<P class=3DBody><A name=3DpgfId-998232></A>The minimum requirements for =
building=20
source code include specifying which source files should be included, =
the=20
directory in which the build should be stored, linking rules, debugging, =
and=20
optimization flags, and included paths.</P>
<P class=3DBody><A name=3DpgfId-998236></A>You can edit your code using=20
Source-Navigator. This chapter explains compiling and linking. For =
information=20
about external stand alone debuggers, see either <A class=3DXRef=20
href=3D"http://sourcenav.sourceforge.net/online-docs/userguide/debugger.h=
tml#45395">Debugger</A>=20
or your debugger's documentation.</P>
<H2 class=3DHeading1><A name=3DpgfId-998246></A>make</H2>
<P class=3DBody><A name=3DpgfId-998250></A>Source-Navigator uses a =
utility called=20
<KBD class=3DCode>make</KBD>. <KBD class=3DCode>make</KBD> combines a =
set of rules=20
for compiling and linking code with a tracking mechanism for determining =
which=20
files must be compiled.</P>
<P class=3DBody><A name=3DpgfId-998254></A>Source-Navigator generates a =
<KBD=20
class=3DCode>makefile</KBD>, which <KBD class=3DCode>make</KBD> uses to =
determine=20
which commands need to be executed in order to build your program.</P>
<H2 class=3DHeading1><A name=3DpgfId-998256></A><A =
name=3Dmarker-998255></A>Build=20
Targets</H2>
<P class=3DBody><A name=3DpgfId-998258></A>A <A =
name=3Dmarker-998257></A>build target=20
is a conceptual object that contains information needed to compile and =
link a=20
project. For example, <KBD class=3DCode>hello.c</KBD> is converted into =
<KBD=20
class=3DCode>hello.o</KBD> before <KBD class=3DCode>hello</KBD> is =
built. To produce=20
the <KBD class=3DCode>hello</KBD> executable, the <KBD =
class=3DCode>hello.o</KBD>=20
object file is linked with any required libraries.</P>
<P class=3DBody><A name=3DpgfId-998259></A>The first time you select =
<SPAN=20
class=3DBold>Build Settings</SPAN>, the <SPAN class=3DBold>Build =
Targets</SPAN> list=20
is empty. After you create a build target, its name appears in the =
list.</P>
<H3 class=3DHeading2><A name=3DpgfId-998261></A><A =
name=3Dmarker-998260></A>Creating a=20
New Build Target</H3>
<P class=3DBody><A name=3DpgfId-998262></A>From the <SPAN =
class=3DBold>Tools</SPAN>=20
menu, select <SPAN class=3DBold>Build Settings </SPAN>to start the <SPAN =
class=3DBold>Build Settings</SPAN> dialog. </P>
<P class=3DFigureTitle><A name=3DpgfId-998266></A>Build Settings =
Dialog</P>
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-3.g=
if">=20
</DIV>
<P class=3DBody><A name=3DpgfId-998267></A>Enter the name of the build =
target in the=20
text entry box and click the <SPAN class=3DBold>Create</SPAN> button. =
The <SPAN=20
class=3DBold>Edit Target</SPAN> dialog opens.=20
<P class=3DBody>See <A class=3DXRef=20
href=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide.ht=
ml#15207">Editing=20
a Target</A>.</P>
<P></P>
<H3 class=3DHeading2><A name=3DpgfId-998271></A>Modifying Build =
Targets</H3>
<P class=3DBody><A name=3DpgfId-998272></A>Rename a build target by =
selecting the=20
target, entering a new name, and clicking the <SPAN =
class=3DBold>Rename</SPAN>=20
button.</P>
<H3 class=3DLabel><A name=3DpgfId-1002480></A>Note</H3>
<P class=3DNote><A name=3DpgfId-1002481></A>Do not highlight the target =
name in the=20
text box or a new target is created.</P>
<P class=3DBody><A name=3DpgfId-998275></A>To edit an existing build =
target, select=20
the target and click the <SPAN class=3DBold>Edit</SPAN> button.</P>
<P class=3DBody><A name=3DpgfId-998276></A>Duplicating a build target is =
useful when=20
a new target is only slightly different from an existing target. To <A=20
name=3Dmarker-998277></A>duplicate an existing build target, select the =
target in=20
the <SPAN class=3DBold>Build Targets</SPAN> list and click the <SPAN=20
class=3DBold>Duplicate</SPAN> button. </P>
<P class=3DBody><A name=3DpgfId-998279></A><A =
name=3Dmarker-998278></A>Delete a build=20
target by selecting it in the <SPAN class=3DBold>Build Targets</SPAN> =
list and=20
click the <SPAN class=3DBold>Delete </SPAN>button. The target is removed =
from the=20
listing.</P>
<H3 class=3DHeading2><A name=3DpgfId-998282></A><A =
name=3Dmarker-998280></A><A=20
name=3D15207></A>Editing a Target</H3>
<P class=3DBody><A name=3DpgfId-998283></A>In the <SPAN =
class=3DBold>Build=20
Targets</SPAN> list, either select the target name and click the <SPAN=20
class=3DBold>Edit</SPAN> button or double-click the target name. The =
<SPAN=20
class=3DBold>Edit Target</SPAN> dialog opens.</P>
<P class=3DFigureTitle><A name=3DpgfId-998287></A>Edit Target Dialog</P>
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-4.g=
if">=20
</DIV>
<H4 class=3DHeading3><A name=3DpgfId-998288></A>Edit Target tabs</H4>
<P class=3DBody><A name=3DpgfId-998289></A>The <SPAN class=3DBold>Build=20
Directory</SPAN>, <SPAN class=3DBold>Target Type</SPAN>, and <SPAN =
class=3DBold>Tool=20
Chain</SPAN> combo-boxes are common to the tabs accessed in the<SPAN =
class=3DBold>=20
Edit Target </SPAN>dialog.</P>
<P class=3DBody><A name=3DpgfId-998308></A></P>
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-5.g=
if">=20
</DIV>
<P class=3DBody><A name=3DpgfId-998312></A>These store information about =
the build=20
target.</P>
<H5 class=3DHeading4><A name=3DpgfId-998313></A>Build Directory</H5>
<P class=3DBody><A name=3DpgfId-998314></A>This is the directory where =
all files=20
generated in the build process are initially stored. By default this is =
blank.=20
If this is left blank, then the project directory is used. To specify =
the=20
directory, either type the directory path or click the "<SPAN=20
class=3DBold>...</SPAN>" button. If you click the "<SPAN =
class=3DBold>...</SPAN>"=20
button, the <SPAN class=3DBold>Open</SPAN> dialog opens: </P>
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-6.g=
if">=20
</DIV>
<P class=3DBody><A name=3DpgfId-998318></A>Select the directory in which =
to store=20
the intermediate files. Click <SPAN class=3DBold>OK</SPAN> to close the =
dialog.=20
The directory appears in the <SPAN class=3DBold>Build Directory</SPAN> =
field.</P>
<H5 class=3DHeading4><A name=3DpgfId-998319></A>Target Type</H5>
<P class=3DBody><A name=3DpgfId-998320></A>Use this combo-box to select =
the type of=20
build target to create. The options are <EM =
class=3DEmphasis>Executable</EM> and=20
<EM class=3DEmphasis>Library</EM>.</P>
<H5 class=3DHeading4><A name=3DpgfId-998321></A>Tool Chain</H5>
<P class=3DBody><A name=3DpgfId-998322></A>A <EM class=3DEmphasis>tool =
chain</EM> is a=20
set of compilers, debuggers, and linkers. The currently available option =
is <EM=20
class=3DEmphasis>GNUPro (native)</EM>.</P>
<H4 class=3DHeading3><A name=3DpgfId-998325></A><A =
name=3Dmarker-998323></A><A=20
name=3D50837></A>Source Files tab</H4>
<P class=3DBody><A name=3DpgfId-998326></A>The <SPAN class=3DBold>Source =
Files=20
</SPAN>tab controls which source files are included in your build =
target. The=20
<SPAN class=3DBold>Project Files</SPAN> and <SPAN =
class=3DBold>Target</SPAN> <SPAN=20
class=3DBold>Files</SPAN> sections contain tree information for the =
selected build=20
target.</P>
<P class=3DFigureTitle><A name=3DpgfId-998337></A>Source Files Tab</P>
<DIV><IMG=20
src=3D"http://sourcenav.sourceforge.net/online-docs/userguide/progide-7.g=
if">=20
</DIV>
<H5 class=3DHeading4><A name=3DpgfId-998341></A>Adding files</H5>
<P class=3DBody><A name=3DpgfId-998343></A><A =
name=3Dmarker-998342></A>To add files to=20
the <SPAN class=3DBold>Target Files</SPAN> list:</P>
<OL>
<LI class=3DNumbered>
<P class=3DBody><A name=3DpgfId-998344></A>Select the files from the =
<SPAN=20
class=3DBold>Project Files</SPAN> list. </P>
<LI class=3DNumberedNext>
<P class=3DBody><A name=3DpgfId-998345></A>Click the <SPAN =
class=3DBold>Add=20
Files</SPAN> button.=20
<P><A name=3DpgfId-998346></A>The files are copied into the <SPAN=20
class=3DBold>Target Files</SPAN> list.</P></LI></OL>
<H5 class=3DHeading4><A name=3DpgfId-998348></A><A =
name=3Dmarker-998347></A>Removing=20
files</H5>
<P class=3DBody><A name=3DpgfId-998349></A>To remove files from the =
<SPAN=20
class=3DBold>Target Files</SPAN> section, select the files to remove and =
click the=20
<SPAN class=3DBold>Clear</SPAN> button. To remove all of the files from =
the <SPAN=20
class=3DBold>Target Files</SPAN> section, click the <SPAN =
class=3DBold>Clear=20
All</SPAN> button.</P>
<H5 class=3DHeading4><A name=3DpgfId-998350></A>Importing files and =
directories</H5>
<P class=3DBody><A name=3DpgfId-998353></A>To <A =
name=3Dmarker-998351></A>import files=20
or <A name=3Dmarker-998352></A>directories into your currently active =
project:</P>
<OL>
<LI class=3DNumbered>
<P class=3DBody><A name=3DpgfId-998354></A>Under <SPAN =
class=3DBold>Import</SPAN>,=20
click either the <SPAN class=3DBold>Files</SPAN> or <SPAN=20
class=3DBold>Directory</SPAN> button. </P>
<LI class=3DNumberedNext>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -