📄 c-config4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Configuration and Build </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-config.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-config3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-config5.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="85039">8.4 Building, Loading, and Unloading Application Modules</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85041"> </a>In the Tornado development environment, application modules for the target system are created and maintained on a separate development host. First, the source code, generally in C or C++, is edited and compiled to produce a relocatable object module. Application modules use VxWorks facilities by virtue of including header files that define operating-system interfaces and data structures. The resulting object modules can then be loaded and dynamically linked into a running VxWorks system over the network. </p><dd><p class="Body"><a name="85042"> </a>The following sections describe in detail the procedures for carrying out cross-development manually (without using the project facility).</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85044">8.4.1 Using VxWorks Header Files</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85046"> </a>Many application modules make use of VxWorks operating system facilities or utility libraries. This usually requires that the source module refer to VxWorks <i class="term">header files</i>. The following sections discuss the use of VxWorks header files.</p><dd><p class="Body"><a name="85048"> </a>VxWorks header files supply ANSI C function prototype declarations for all global VxWorks routines. The ANSI C prototypes are conditionally compiled; to use them, the preprocessor constant <b class="symbol_UC">__STDC__</b> must be defined. ANSI C compilers define this constant by default. VxWorks provides all header files specified by the ANSI X3.159-1989 standard.</p><dd><p class="Body"><a name="85050"> </a>VxWorks system header files are in the directory <i class="textVariable">installDir</i><b class="file">/target/h</b> and its subdirectories.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="87081"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>The notation <b class="operator">$(</b><b class="symbol_UC">WIND_BASE</b><b class="operator">)</b> is used in makefiles to refer to the Tornado installation directory. This chapter uses that notation because makefiles are the most convenient way to run the Tornado compilation tools. If you run the compiler from the Windows command prompt, write <b class="operator">%</b><b class="symbol_UC">WIND_BASE</b><b class="operator">%</b> instead.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85060">VxWorks Header File: <b class="file">vxWorks.h</b></a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85062"> </a><b class="file"></b>The header file <b class="file">vxWorks.h</b> contains many basic definitions and types that are used extensively by other VxWorks modules. Many other VxWorks header files require these definitions. Thus, this file must be included first by every application module that uses VxWorks facilities. Include <b class="file">vxWorks.h</b> with the following line:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85063">#include "vxWorks.h"</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85064">Other VxWorks Header Files</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85065"> </a>Application modules can include other VxWorks header files as needed to access VxWorks facilities. For example, an application module that uses the VxWorks linked-list subroutine library must include the <b class="file">lstLib.h</b> file with the following line:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85066">#include "lstLib.h"</a></b></pre></dl><dd><p class="Body"><a name="85067"> </a>The manual entry for each library lists all header files necessary to use that library.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85068">ANSI Header Files</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85070"> </a>All ANSI-specified header files are included in VxWorks. (UNIX)</p><dd><p class="Body"><a name="85071"> </a>This implies that many familiar UNIX header files are available under VxWorks as well. There are two file names that differ from the usual UNIX names: <b class="file">a_out.h</b> (which corresponds to the UNIX <b class="file">a.out.h</b>) and <b class="file">stdlib.h</b> (which corresponds to the UNIX <b class="file">malloc.h</b>)</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85072">The <b class="command">-I</b> Compiler Flag</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85074"> </a>By default, the compiler searches for header files first in the directory of the source module and then in directories that apply only to the development host. With the GNU compiler, you can avoid these host-system include directories with the compilation flag <b class="command">-nostdinc</b>. To access the VxWorks header files, the compiler must also be directed to search<b class="file"> $(WIND_BASE)/target/h</b>. Thus, the following option flag is standard for VxWorks compilation:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85076">-I $(WIND_BASE)/target/h</a></b></pre></dl><dd><p class="Body"><a name="85077"> </a>Some header files are located in subdirectories. To refer to header files in these subdirectories, be sure to specify the subdirectory name in the include statement, so that the files can be located with a single <b class="command">-I</b> specifier. For example:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85078">#include "vxWorks.h" #include "sys/stat.h"</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85079">VxWorks Nested Header Files</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85081"> </a>Some VxWorks facilities make use of other, lower-level VxWorks facilities. For example, the <i class="acronym_lc">tty</i> management facility uses the ring buffer subroutine library. The <i class="acronym_lc">tty</i> header file <b class="file">tyLib.h</b> uses definitions that are supplied by the ring buffer header file <b class="file">rngLib.h</b>.</p><dd><p class="Body"><a name="85082"> </a>It would be inconvenient to require you to be aware of such include-file interdependencies and ordering. Instead, all VxWorks header files explicitly include all prerequisite header files. Thus, <b class="file">tyLib.h</b> itself contains an include of <b class="file">rngLib.h</b>. (The exception to this is the basic VxWorks header file <b class="file">vxWorks.h</b>, which all other header files assume is already included.)</p><dd><p class="Body"><a name="85083"> </a>This, in turn, might lead to a problem: a header file could get included more than once, if one were included by several other header files, or if it were also included directly by the application module. Normally, including a header file more than once generates fatal compilation errors, because the C preprocessor regards duplicate definitions as potential sources of conflict. To avoid this problem, all VxWorks header files contain conditional compilation statements and definitions that ensure that their text is included only once, no matter how many times they are specified by include statements. Thus, an application module can include just those header files it needs directly, without regard for interdependencies or ordering, and no conflicts arise.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85085">Internal Header Files</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85090"> </a><a href="c-config4.html#85096">Table 8-2</a> lists the subdirectories of <i class="textVariable">installDir</i><b class="file">/target/h</b> used by VxWorks for internal header files. These header files are, for the most part, not intended for applications. The following subdirectories are exceptions, and are sometimes required by application programs:</p></dl><dl class="margin"><ul class="BulletSingle" type="disc"><li><a name="85091"> </a><i class="textVariable">installDir</i><b class="file">/target/h/net</b>, which is used by network drivers for specific network controllers. </li></ul><ul class="BulletSingle" type="disc"><li><a name="85092"> </a><i class="textVariable">installDir</i><b class="file">/target/h/rpc</b>, which is used by applications using the remote procedure call library.</li></ul><ul class="BulletSingle" type="disc"><li><a name="85151"> </a><i class="textVariable">installDir</i><b class="file">/target/h/sys</b>, which is used by applications using standard POSIX functions.<p class="table"><h4 class="EntityTitle"><a name="85096"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 8-2: Include Subdirectories</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85100"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Subdirectory</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="85102"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Use</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85104"> </a> <i class="textVariable">installDir</i><b class="file">/target/h/arch</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85106"> </a>Architecture-specific header files. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85108"> </a><i class="textVariable">installDir</i><b class="file">/target/h/arpa</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85110"> </a>Fundamental Internet header file. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85112"> </a><i class="textVariable">installDir</i><b class="file">/target/h/make</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85114"> </a>Generic makefile information. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85116"> </a><i class="textVariable">installDir</i><b class="file">/target/h/drv</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85118"> </a>Device-driver header files. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85120"> </a><i class="textVariable">installDir</i><b class="file">/target/h/net</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85122"> </a>Network header files. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85124"> </a><i class="textVariable">installDir</i><b class="file">/target/h/netinet</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85126"> </a>Internet protocol header files. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85128"> </a><i class="textVariable">installDir</i><b class="file">/target/h/private</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85130"> </a>VxWorks private header files. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85132"> </a><i class="textVariable">installDir</i><b class="file">/target/h/rpc</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85134"> </a>Remote Procedure Call (RPC) header files. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85136"> </a><i class="textVariable">installDir</i><b class="file">/target/h/rw</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85138"> </a>Header files for Tools.h++ from Rogue Wave (Optional). </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85140"> </a><i class="textVariable">installDir</i><b class="file">/target/h/sys</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85142"> </a>System header files specified by POSIX. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85144"> </a><i class="textVariable">installDir</i><b class="file">/target/h/types</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85146"> </a>Data types used by the system. </div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="85148"> </a><i class="textVariable">installDir</i><b class="file">/target/h/wdb</b> </div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="85150"> </a>Target-agent declarations. </div></td></tr><tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -