home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 3 / Tools.exe / tlink32.txt < prev    next >
Text File  |  1998-02-09  |  16KB  |  347 lines

  1. TLINK32 Help
  2.  
  3. TLink32 is a command-line tool that combines object modules (.OBJ files),
  4. library modules (.LIB files), and resources to produce executable files (.EXE and .DLL files).
  5. Because the compiler automatically calls a linker, you don't need to explicitly use a linker unless
  6. you suppress the linking stage of compiling (see the -c compiler option).
  7. TLINK32 and ILINK32 are invoked from the command line to link a configuration file called
  8. TLINK32.CFG (ILINK32 uses ILINK32.CFG), an optional response file, and command-line
  9. options to link object modules, libraries, and resources into an executable file.
  10.  
  11. Both TLINK32 and ILINK32 link 32-bit Windows code and use the 32-bit resource linker,
  12. RLINK32.DLL.
  13.  
  14. The linker syntax controls how the linkers work. Linker command-line options are
  15. case-sensitive. Unless specified, instructions and options for TLINK32 also apply to ILINK32.
  16. The linkers can also use a configuration file called TLINK32.CFG for options that you'd
  17. normally type at the command-line.
  18.  
  19. Syntax
  20.  
  21. TLINK32 | ILINK32 [@respfile][options] startup myobjs, [exe], [mapfile], [libraries], [deffile],
  22. [resfile]
  23.  
  24. [@respfile]    A response file is an ASCII file that lists linker options and file names that you
  25. would normally type at the command line. By placing options and files names in a response file,
  26. you can save the amount of keystrokes you need to type to link your application.
  27.  
  28. [options] Linker options that control how the linker works. For example, options specify
  29. whether to produce an .EXE or a DLL file. Linker options must be preceded by either a slash (/)
  30. or a hyphen (-).
  31.  
  32. startup   A Borland initialization module for executables or DLLs that arranges the order of the
  33. various segments of the program. Failure to link in the correct initialization module usually
  34. results in a long list of error messages telling you that certain identifiers are unresolved, or that
  35. no stack has been created.
  36.  
  37. myobjs    The .OBJ files you want linked. Specify the path if the files aren't in the current
  38. directory. (The linker appends an .OBJ extensions if no extension is present.)
  39.  
  40. [exe]     The name you want given to the executable file (.COM, .EXE, or .DLL). If you don't
  41. specify an executable file name, TLINK derives the name of the executable by appending .EXE
  42. or .DLL to the first object file name listed. (The linker assumes or appends an .EXE extensions
  43. for executable files if no extension is present. It also assumes or appends a .DLL extension for
  44. dynamic link libraries if no extension is present.)
  45.  
  46. [mapfile] Is the name you want given to the map file. If you don't specify a name, the map
  47. file name is given the same as exefile (but with the .MAP extension). (The linker appends a
  48. .MAP extensions if no extension is present.)
  49.  
  50. [libraries]    The library files you want included at link time. Do not use commas to separate
  51. the libraries listed. If a file is not in the current directory or the search path (see the /L option)
  52. then you must include the path in the link statement. (The linker appends a .LIB extension if no
  53. extension is present.)
  54.  
  55. The order in which you list the libraries is very important; be sure to use the order defined in this
  56. list:
  57.       Code Guard libraries (if needed)
  58.       List any of your own user libraries, noting that if a function is defined more than once,
  59. the linker uses the first definition encountered
  60.       If you're creating a DOS overlay, link the DOS overlay module OVERLAY.LIB
  61.       DPMI libraries (DOS DPMI applications only)
  62.       IMPORT.LIB (if you're creating an executable that uses the Windows API)
  63.  
  64.  Math libraries (if needed)
  65.       Runtime libraries associated with your memory model and platform
  66. [deffile] The module definition file for a Windows executable. If you don't specify a
  67. module definition (.DEF) file and you have used the /Twe or /Twd option, the linker creates an
  68. application based on default settings. (The linker appends a .DEF extension if no extension is
  69. present.)
  70. [resfile] A list of .RES files (compiled resource files) to bind to the executable. (The linker
  71. appends an .RES extension if no extension is present.)
  72.  
  73. TLINK32 uses a configuration file called TLINK32.CFG for options that you would normally
  74. type at the command line (note that configuration files can contain only options, not file names).
  75. Configuration files let you save options you use frequently, so you do not have to continually
  76. retype them.
  77. TLINK32 looks for TLINK32.CFG in the current directory, then in the directory from which it
  78. was loaded.
  79. The following TLINK32.CFG file tells TLINK32 to look for libraries first in the ..\LIB directory
  80. of your Borland compiler, then in C:\WINAPPS\LIB, to include debug information in the
  81. executables it creates, to create a detailed segment map, and to produce a Windows executable
  82. (.EXE not .DLL).
  83.  
  84. ;Sample TLINK32.CFG file
  85.  
  86. /Lc:\BORLANDC\LIB;c:\WINAPPS\LIB
  87. /v /s
  88.  
  89. /Tpe
  90.  
  91. Note: If you specify command-line options in addition to those recorded in a configuration file,
  92. the command-line options override any conflicting configuration options.
  93.  
  94. You can use response files with the command-line linkers to specify linker options.
  95. Response files are ASCII files that list linker options and file names that you would normally
  96. type at the command line. Response files allow you longer command lines than most operating
  97. systems support, plus you don't have to continually type the same information. Response files
  98. can include the same information as configuration files, but they also support the inclusion of file
  99. names.
  100. Unlike the command line, a response file can be several lines long. To specify an added line, end
  101. a line with a plus character (+) and continue the command on the next line. Note that if a line
  102. ends with an option that uses the plus to turn it on (such as /v+), the + is not treated as a line
  103. continuation character (to continue the line, use /v+ +).
  104.  
  105. If you separate command-line components (such as .OBJ files from .LIB files) by lines in a
  106. response file, you must leave out the comma used to separate them on the command line. For
  107. example,
  108.  
  109. /c c0ws+
  110.  
  111. myprog,myexe +
  112. mymap +
  113.  
  114. mylib cws
  115.  
  116. leaves out the commas you'd have to type if you put the information on the command line:
  117.  
  118. TLINK32 /c c0ws myprog,myexe,mymap,mylib cws
  119.  
  120. To use response files,
  121.  
  122. 1.   Type the command-line options and file names into an ASCII text file and save the file.
  123. Response files shipped with Ebony have an .RSP extension.
  124. 2.   Type TLINK32 @[path]RESFILE.RSP where RESFILE.RSP is the name of your
  125. response file.
  126.  
  127. You can specify more than one response file as follows:
  128.  
  129. tlink32 /c @listobjs.rsp,myexe,mymap,@listlibs.rsp
  130.  
  131. Note: You can add comments to response files using semicolons; the linker ignores any text on a
  132. line that follows a semicolon.
  133.  
  134. You can pass options and files to TLINK through the command-line compiler (BCC32.EXE) by
  135. typing file names on the command line with explicit .OBJ and .LIB extensions. For example,
  136.  
  137. BCC32 mainfile.obj sub1.obj mylib.lib
  138.  
  139. links MAINFILE.OBJ, SUB1.OBJ, and MYLIB.LIB to produce the executable
  140. MAINFILE.EXE.
  141. Note: By default, BCC32 starts TLINK32 (or ILINK) with the files C0W32.OBJ, CW32.LIB,
  142. and IMPORT32.LIB (initialization module, run-time library, and Windows import library). In
  143. addition, both compilers always pass the linkers the /c (case-sensitive link) option.
  144.  
  145.  
  146. TLINK32 assumes or appends these extensions to file names that have
  147. none:
  148.  
  149.   o  .OBJ for object files
  150.  
  151.   o  .EXE for executable files
  152.  
  153.   o  .DLL for dynamic-link libraries
  154.  
  155.   o  .MAP for map files
  156.  
  157.   o  .LIB for library files
  158.  
  159.   o  .DEF for module-definition files
  160.  
  161.   o  .RES for resource files
  162.  
  163. TLINK32 options
  164. =============
  165. Unless otherwise specified, options work with both TLINK and TLINK32.
  166. Options are case-sensitive and must be preceded by either a slash (/)
  167. or a hyphen (-). To turn off a default option, place a hyphen after
  168. the option at the command-line (for example, -P- or /P-). You can
  169. place options anywhere in the command line. You don't need spaces
  170. after options (/m/f/c is the same as /m  /f  /c), but you must
  171. separate options and files with a space.
  172.  
  173. The following table lists the TLINK options. A more detailed
  174. explanation of options follows the table.
  175.  
  176. Option    For       Description
  177. ------    ---       -----------
  178.  
  179. /A:dd (align pages) specifies page alignment for code and data within
  180. the executable file where dd must be a decimal power of 2. For
  181. example, if you specify an alignment value of /A:12, the sections in
  182. the image are stored on 4096-byte boundaries. The operating system
  183. seeks pages for loading based on this alignment value. The default is
  184. /A:9, which means sections are aligned on 512-byte boundaries within
  185. the executable file.
  186.  
  187. /B:xxxxxx (base address) specifies an image base address for an
  188. application. If this option is used, internal fixups are removed from
  189. the image, and the requested load address of the first object is set
  190. to the hexadecimal number given with the option. All successive
  191. objects are aligned on 64K linear address boundaries. This option
  192. makes applications smaller on disk, and improves both load-time and
  193. run-time performance since the operating system no longer has to apply
  194. internal fixups. Because NT loads all .EXE images at 64K, you're
  195. advised to link all .EXEs with /B:0x10000.
  196.  
  197. /c (case sensitivity) makes the case significant in public and
  198. external symbols.
  199.  
  200. /Enn (maximum errors) specifies the maximum number of errors the
  201. linker reports before terminating. /E0 (the default) reports an
  202. infinite number of errors (that is, as many as possible).
  203.  
  204. /Gx (Goodies) are options where x can be
  205.      n = Discard nonresident name table. (16-bit only)
  206.      r = Transfer resident names to nonresident table. (16-bit only)
  207.      m = (TLINK32) Put mangled names in map file; this can help you
  208.          identify how names are mangled.
  209.  
  210. /i (uninitialized trailing segments) outputs uninitialized trailing
  211. segments into the executable file even if the segments don't contain
  212. data records.
  213.  
  214. /L (library search paths) lets you list directories for TLINK to
  215. search if you don't type an explicit path for a library or the C or
  216. C++ initialization module. TLINK searches the current directory first
  217. (where you typed TLINK). For example:
  218.  
  219.      TLINK /Lc:\BC4\lib;c:\mylibs splash logo,,,utils .\logolib
  220.  
  221. first searches the current directory for UTILS.LIB, then searches
  222. C:\BC4\LIB, then C:\MYLIBS. Because @WORD(LOGOLIB) explicitly names
  223. the current directory, TLINK doesn't search the libraries specified
  224. with the /L option to find LOGOLIB.LIB.
  225.  
  226. /M (map mangled) maps with mangled public names.
  227.  
  228. /n (ignore default libraries) ignores default libraries specified by
  229. some compilers. Use this option when linking modules that are written
  230. in another language.
  231.  
  232. /o (overlays) overlays code in all the modules or libraries that
  233. follow the option on the command line (this option works for DOS
  234. applications only). Use /o- on the command line to turn off overlays.
  235. If you specify a class name after this option, all the segments in
  236. that class are overlaid (you can do this for multiple classes). If you
  237. don't specify any name after this option, all segments of classes
  238. ending with CODE are overlaid. This option uses the default overlay
  239. interrupt number of 3FH. To specify a different interrupt number, use
  240. /o#xx, where xx is a two-digit hexadecimal number.
  241.  
  242. /P (pack code segments) combines as many code segments as possible in
  243. one physical segment up to (and never greater than) the code-segment
  244. packing limit. TLINK starts a new segment if it needs to. The default
  245. code-segment packing limit is 8,192 bytes (8K). To change it, use /P=n
  246. where n specifies the number of bytes between 1 and 65,536. You would
  247. probably want the limit to be a multiple of 4K under 386 enhanced mode
  248. because of the paging granularity of the system.
  249.  
  250. Although the optimum segment size in 386 enhanced mode is 4K, the
  251. default code-segment packing size is 8K because typical code segments
  252. are from 4K to 8K and 8K might pack more efficiently.
  253.  
  254. Because each maintained segment has some system overhead, code-segment
  255. packing typically increases performance. /P- turns off code-segment
  256. packing (useful if you've turned it on in the configuration file and
  257. want to disable it for a particular link).
  258.  
  259. /s (detailed segment map) creates a map file with the same features as
  260. the /m option, but adds a detailed segment map. If you don't specify
  261. map file options (/m, /s, or /x), then the option Map File|Segments is
  262. used. For each segment in each module, this map file includes the
  263. address, length in bytes, class, segment name, group, module, and ACBP
  264. information. If the same segment appears in more than one module, each
  265. module appears as a separate line. Except for the ACBP field, the
  266. information in the detailed segment map is self-explanatory.
  267.  
  268. The ACBP field encodes the A (alignment), C (combination), and B (big)
  269. attributes into a set of four bit fields, as defined by Intel. TLINK
  270. uses only three of the fields, the A, C, and B fields. The ACBP value
  271. in the map is printed in hexadecimal. The following values of the
  272. fields must be OR'ed together to arrive at the ACBP value printed.
  273.  
  274. Field                    Value     Description
  275. -----                    -----     -----------
  276. The A field (alignment)       00   An absolute segment.
  277.                     20   A byte-aligned segment.
  278.                     40   A word-aligned segment.
  279.                     60   A paragraph-aligned segment.
  280.                     80   A page-aligned segment.
  281.                     A0   An unnamed absolute portion of
  282.                          storage.
  283.  
  284. The B field (big)        00   Segment less than 64K.
  285.                     02   Segment exactly 64K.
  286.  
  287. The C field (combination)     00   Cannot be combined.
  288.                     08   A public combining segment.
  289.  
  290. With the /s option, public symbols with no references are flagged
  291. "idle." An idle symbol is a publicly-defined symbol in a module that
  292. wasn't referenced by an EXTDEF record by any other module included in
  293. the link. For example, this fragment from the public symbol section of
  294. a map file indicates that symbols Symbol1 and Symbol3 aren't
  295. referenced by the image being linked:
  296.  
  297.      0002:00000874  Idle Symbol1
  298.      0002:00000CE4       Symbol2
  299.      0002:000000E7  Idle Symbol3
  300.  
  301. /S:xxxxxx (stack size) sets the application stack size in hexadecimal
  302. where xxxxxx is a hexadecimal string. Specifying the stack size with
  303. /S overrides any stack size setting in a module-definition file.
  304.  
  305. /Tpx (protected target) produces a protected mode .EXE (/Tpe) or .DLL
  306. file (/Tpd).
  307.  
  308. /v (debugging information) includes debugging information in the
  309. executable file. If this option is found anywhere on the command line,
  310. debugging information is included in the executable file for all
  311. object modules that contain debugging information. You can use the /v+
  312. and /v- options to selectively enable or disable debugging information
  313. on a module-by-module basis (but not on the same command line as /v).
  314. For example, the command
  315.  
  316.      TLINK32 mod1 /v+ mod2 mod3 /v- mod4
  317.  
  318. includes debugging information for modules mod2 and mod3, but not for
  319. mod1 and mod4.
  320.  
  321. /wxxx (warning control) turns on (/wxxx) or off (/w-xxx) TLINK
  322. warnings, where xxx can be one of the following (defaults mean TLINK
  323. will send the warning without you specifically turning it on):
  324.  
  325. Option         Description
  326. ------         -----------
  327. bdl       Using based linking in DLLs (might cause the DLL to
  328.           malfunction)
  329.  
  330. def       No .DEF file; using defaults
  331.  
  332. dpl       Warn duplicate symbol in .LIB
  333.  
  334. dup       Duplicate symbol (warning for .OBJs)
  335.  
  336. ent       No entry point
  337.  
  338. imt       Import doesn't match previous definition
  339.  
  340. srf       Self-relative fixup overflowed
  341.  
  342.  
  343. /x (no map file) tells TLINK to not generate a map file. TLINK usually
  344. creates map files that list segments in the program, the program start
  345. address, and any TLINK warning or error messages (the Map
  346. File|Segments option, which has no command-line option, is on by
  347. default).