📄
字号:
size=2>会根据你在开始创建工程时选择的工程模板来自动地设置子系统的选项; </FONT>
<LI><B><FONT size=2>子系统 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>ID/</FONT><FONT
size=2>用户 </FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>ID(Subsystem ID/UserID):</B> </FONT><FONT
size=2>和子系统项一样,这个选项也是由 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>CodeWarrior
</FONT><FONT size=2>自动设置的。具体系统对应的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>ID </FONT><FONT
size=2>为:</FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>Windows 3.1</FONT><FONT size=2>,</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Windows 95 </FONT><FONT
size=2>和 </FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>Windows NT 3.5 </FONT><FONT size=2>的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>ID </FONT><FONT
size=2>为 </FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>3.10</FONT><FONT size=2>,</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Windows NT 4
</FONT><FONT size=2>的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>ID </FONT><FONT
size=2>为 </FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>4.00</FONT><FONT size=2>;</FONT>
<LI><B><FONT size=2>生成连接映射</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>(Generate Link
Map):</B> </FONT><FONT
size=2>这个选项允许你生成一个文本文件,其中包含了程序中使用到的所有的类和函数的详细信息。当需要通过匹配变量或函数名的地址来调试代码时,这个选项就非常有用了;</FONT>
<LI><B><FONT size=2>生成 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>SYM </FONT><FONT
size=2>文件</FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>(Generate SYM File):</B> </FONT><FONT
size=2>这个选项允许你在连接过程中生成一个符号文件。大多数的调试器在进行调试时需要一个符号文件来逐步调试你的源代码。我们将在第五课中详细讨论这个内容。此外,你还可以通过选中生成
</FONT><FONT face="Arial, Helvetica, sans-serif" size=2>CV
</FONT><FONT size=2>信息项</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>(Generate CV Info
item)</FONT><FONT size=2>来生成一个可用于 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>CodeView </FONT><FONT
size=2>的符号文件。</FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>CodeView </FONT><FONT size=2>是一个流行的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Windows </FONT><FONT
size=2>调试工具;</FONT>
<LI><STRONG><FONT size=2>生成 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>CV </FONT><FONT
size=2>信息</STRONG><B><FONT
face="Arial, Helvetica, sans-serif">(</FONT></FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Generate CV Info):</B>
</FONT><FONT size=2>生成一个可用于 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>CodeView </FONT><FONT
size=2>的符号文件。</FONT><FONT face="Arial, Helvetica, sans-serif"
size=2>CodeView </FONT><FONT size=2>是一个流行的 </FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Windows </FONT><FONT
size=2>调试工具;</FONT>
<LI><B><FONT size=2>命令文件</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>(Command File):</B>
</FONT><FONT
size=2>这个选项要你选择一个用于指示复杂的连接选项设置的文本文件。该文件称为连接器命令文件。它被使用来指定要导入和导出哪些符号。除非你正在编写一个特殊目的的代码,你才不需要一个连接器文件。</FONT>
</LI></UL>
<P><FONT face="Arial, Helvetica, sans-serif"
size=2> </FONT><FONT
size=2>正如你所知的,连接器的设置过程是非常复杂的。但是,在多数情况下,你不需要修改连接器的默认设置。</FONT><FONT
face="Arial, Helvetica, sans-serif" size=2>Metrowerks </FONT><FONT
size=2>公司的开发人员已经帮助你很好地解决了这个问题。</FONT></P>
<HR>
<P>附原文:</P>
<P><FONT face="Arial, Helvetica, sans-serif" color=#000000
size=3><B><B>Step Two: Link your Program's
Components</B></B><BR></FONT><BR></P><FONT
face="Arial, Helvetica, sans-serif" size=2>
<P>After the compiler compiles your code, the linker links together
the files that make up your program.</P>
<P>The linker is responsible for combining your compiled code, which
may be located in various files after they are compiled, and
connecting the files together, along with any libraries the program
requires. Linking makes sure each piece of code knows how to find
the other elements of your program. For example, the linker modifies
the machine code so that your call to printf() gets correctly routed
to the MSL library function printf(), which does the all of the
magic necessary to implement console I/O.</P>
<P>When you write a program, you split your code into functions that
are stored in different files and are compiled to a single output
file. In the case of the Hello World program I've been using as an
example, this output file is an application. In some cases,
functions used in a program may not even be stored in the same
output file. When would this happen? When you write an application,
for example, that contains a lot of code that is reused in several
parts of your program, you might compile all of that reusable code
into a single shared DLL. When you do this, the application can
still access the code, but it needs to know where and how to find it
when it needs it, hence the need for linking.</P>
<P><B><FONT size=+1>Types of Linking</FONT></B></P>
<P>In programming, a link is a pointer, either to an object, such as
a compiled function, or to data, such as a variable or an array.
There are two ways to link: hard linking and soft linking. </P>
<P>Hard linking occurs when all of the code is accounted for at link
time. That is, if a function is used, the linker knows exactly where
it is at link time and can create a direct link to it.</P>
<P>Soft linking (also known as weak linking) is when some of the
code may not be accounted for at link time, but you know that it is
in a DLL that will be accessible at runtime. In this case, the
linker can tell your application to search for the DLL when it is
needed.</P>
<P>Soft linking is the method used by many elements of your
computer's operating system. Next, we'll take a look at some of the
options that the linker provides.</FONT></P>
<P><FONT face="Arial, Helvetica, sans-serif" color=#000000
size=3><B><B>A Detailed Look at
Linking</B></B><BR></FONT><BR></P><FONT
face="Arial, Helvetica, sans-serif" size=2>
<P>To further appreciate the functionality of the CodeWarrior linker
for the Windows platform, you need to understand how you can
configure the CodeWarrior linker to accomplish what you need.</P>
<P><B><FONT size=+1>Configure the Linker to Suit your
Needs</FONT></B></P>
<P>The choices in this lesson appear in the x86 version of the
CodeWarrior linker panel (Figure 4-1). But many of the terms used in
the x86 linker are applicable to other linkers.</P>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD><IMG height=421
alt="Figure. 4-1 The x86 linker settings window."
src="第四课 连 接.files/icwwL4_fig1.gif" width=627 align=left>
</TD></TR>
<TR>
<TD align=middle><FONT size=1><I>Figure. 4-1 The x86 linker
settings window.</I></FONT> </TD></TR></TBODY></TABLE>
<P>Open the Settings window by choosing "Project Name" Settings from
the Edit menu. (Project_Name is the currently active project -- in
this case, Hello World x86.) Click on the x86 Linker (or similar)
tab in the Settings window.</P>
<P>Let's take a look at some of the linker options:
<UL>
<LI><B>Entry Point Usage:</B> Under the Windows OS architecture,
each code module has a number of entry points that may or may not
be optional, depending on the type of code you are building. The
nature of these entry points depends upon the type of output file
you're making (application, library, or DLL) and other factors.
The host OS uses this entry point information to properly call a
DLL's initialization functions when an application demands its
services. Most often, you will leave this set to Default as shown
in Figure 4-1. This lets CodeWarrior automatically set up the
proper entry points for the output file, based upon your choice of
target in the x86 Target panel.
<LI><B>Subsystem: </B>There are several settings here. Of interest
to you are the Native, Windows CUI, and Windows GUI selections.
The Native setting is for building drivers and other exotic system
modules. The Windows CUI setting is for those applications
sporting a console-style user interface (hence the name CUI). The
Windows GUI choice supports applications that rely on the Windows
graphic user interface (GUI). You'll notice that our simple,
console-based Windows application uses the CUI subsystem, as
expected. Normally, CodeWarrior sets the subsystem for you
automatically when you choose a CodeWarrior project template to
construct the project file.
<LI><B>Subsystem ID/UserID:</B> Like the subsystem item, this item
is typically set for you automatically. For the curious: Windows
3.1, Windows 95, and Windows NT 3.5 have an ID of 3.10, while
Windows NT 4 has an ID of 4.00.
<LI><B>Generate Link Map:</B> This option allows you to generate a
text file that contains detailed information on the classes and
functions used throughout your program. This can be extremely
helpful when debugging code by matching addresses to variable or
function names.
<LI><B>Generate SYM File:</B> This option allows you to generate a
symbol file during the link process. Most debuggers require a
symbol file in order to step through your source code when
debugging. This is discussed in more detail in Lesson 5. You can
also generate a symbol file for CodeView, a popular Windows
debugging tool, by checking the Generate CV Info item.
<LI><B>Generate CV Info:</B> Generates a symbol file for CodeView,
a popular Windows debugging tool.
<LI><B>Command File:</B> This item lets you pick the name of an
optional text file that directs sophisticated linking options.
Called the linker command file, you use it to specify which
symbols to import and export, and other advanced linking
operations. Unless you're writing special-purpose code, you won't
normally need a linker command file. </LI></UL>
<P>As you can see, the linker can be a relatively complex piece of
software machinery. Luckily, in many cases, the default settings
will suffice. Very rarely will you have to tweak the linker settings
to get your programs to work. The folks at Metrowerks have done an
excellent job of managing this thankless job for you. Yay,
CodeWarrior!</FONT></P>
<P> </P></TD></TR></TBODY></TABLE></CENTER></DIV></TD></TR>
<TR>
<TD width="100%">
<P align=right><NOBR><INPUT onclick=self.close(); type=button value="关闭此窗口 "></NOBR>
</P></TD></TR>
<TR>
<TD width="100%">
<HR width="96%" color=#000000 noShade SIZE=1>
</TD></TR>
<TR>
<TD class=font width="100%">
<P align=center>Copyright(C) 2000 <A
href="http://www.tsinghua-solution.com.cn/"
target=_blank>北京清华北方思路信息技术有限公司</A> 版权所有<BR>未经许可,不得转载、摘登、结集出版<BR>联系电话:(8610)-62978899-146</P></TD></TR></TBODY></TABLE></CENTER></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -