To control running the linker from the IDDE, set options in the Linker subpage on the Build page of the IDDE's Project Settings dialog box.
- Environment Variables
- Operational Modes
- Error Messages
- Operation and Design
- Module Definition Files
OPTLINK derives its spectacular speed from being written entirely in hand- tuned assembly language, making maximal use of multithreading and processor scheduling. It does full links faster than more pedestrian linkers do incremental links.
OPTLINK combines object (.obj) and library (.lib) files into a single file that is executable by the operating system. OPTLINK can optionally create memory maps and symbol tables that are useful for debugging.
OPTLINK works with modules in Intel OMF format (.obj file), including those generated by standard assemblers, compilers and standard object module libraries. The output files produced have all address assignments resolved and are in one of these standard formats:
- 16 bit .com/.sys/.bin memory image format (MSDOS)
- 16 bit DOS .exe relocatable executable MZ format (MSDOS)
- 16 bit segmented .exe NE format (Windows 3.x)
- 32 bit .exe dos extender format (DOSX)
- 32 bit .exe PE format (Win32)
These features combine to create an environment in which you can create large programs, despite apparent memory constraints.
- Executes faster than any other method for creating executable files. Removal of duplicate records (CVPACK) is built in.
- Successfully builds huge applications, including debug information.
- Smart linking
- Unlike others, recursively eliminates unreferenced code. Also eliminates unreferenced uninitialized global variables, see /PACKFUNCTIONS.
- Efficient program generation options
- Builds smaller, more efficient, faster loading and even faster running 16-bit programs by packing code and data, plus converting intra-segment far calls to near calls, see /PACKCODE, /PACKDATA, /EXEPACK, /FARCALLTRANSLATION.
- Cross referencing
- Optionally included within map output. Every global symbol and the module name( s) of where defined and referenced is listed, see /XREF.
- Environment use
- Dedicated environment variable usage simplifies searches.
- Virtual memory system
- When DOS hosted, automatically uses EMS memory, XMS memory, or disk storage, whichever is available.
Option switch precedenceSwitches are read and processed in lexical order. Any subsequent switch overrides any previous switch setting.
- The optlinks.cfg configuration file.
- The LINK environment variable.
- The OPTLINKS environment variable.
- Command line and indirect response file in the order supplied. Recognizes the most recent switch syntax selected.
|LIB||Supplies paths to search for libraries, object files, and resource files. See also /SCANLIB.|
|TMP||Supplies a path used by OPTLINK for its virtual memory file. Otherwise, the current directory is used. OPTLINK's performance can be severely slowed when its virtual memory file must be stored across a network.|
|LINK||Supplies linker switch settings. Recognized for Microsoft LINK compatibility. See also /SCANLINK.|
|OPTLINKS||Supplies linker switch settings. OPTLINKS is scanned after the LINK variable and can override any previous settings specified.|
|OBJ||Supplies paths to be searched by OPTLINK for .obj files not found in the current working directory. Paths specified by OBJ are always searched before any paths specified by the LIB environment variable.|
|PATH||Supplies paths to be searched by OPTLINK for any stub .exe file specified in the .def file.|
set OPTLINKS=/IGThe environment variables can be overridden by command line input. Every switch can be changed, since it has an opposite.
Versions of OPTLINK
|linknd.dll||DLL version for use in IDDE|
|link.exe||Win32 command line version|
|lnkr.exe||DOS real mode version (obsolete)|
Optimizing Linker PerformanceFor fast execution of the linker, follow these guidelines.
- Disable relocation checks by using the /NORELOCATIONCHECK option.
- If the /MAP option is being used to create a .map file, disable sorting of the map by using the /MAP:address option.
- If the /MAP option is being used to create a .map file, disable placement of line number information in the map by using the /NOLINENUMBERS option (the default).
- If the executable file is a Windows program, use the /RC option to add resources to the executable file.
- If running OPTLINK from a Windows DOS box,
use the DPMI
version (link.exe) and set the DOS box
.pif file parameters in dosprmpt.pif as follows:
XMS required: 0XMS memory not locked (-1 desired)
EMS required: 0EMS memory not locked (-1 desired)
- Configure a small RAM disk so more EMS, XMS, or DPMI memory is available for OPTLINK.
- Avoid linking to a network server.
In all modes of operation, OPTLINK commands, switches and parameters are the same.
Command Line and Interactive OperationCommand line operation of OPTLINK uses the following syntax:
LINK obj[,out[,map[,lib[,def[,res]]]]]For interactive operation input LINK followed by any option switches (described later) and press Enter. OPTLINK then prompts for responses. Option switches may be entered after any response.
OPTLINK parameters include the following:
- One or more input (.obj) file names.
If multiple names are
supplied, they may be joined by "+" characters or blank spaces, but
the comma separates the four parts of the command line. If more
names are required than are able to fit onto the command line, a "+"
immediately before the end of the line makes the list continue to the
Wild-card characters "?" and "*" to specify multiple files are allowed. If specific names are preceded or followed by wild-card references, those modules specifically named will not be included twice. At the end of the input list, use specific data or a "+" character to invoke the default choices. If neither is supplied, operation switches to the interactive mode, and OPTLINK prompts for the remaining inputs. The "#" character tells OPTLINK to ignore the rest of the comment characters following on that line.
- Specifies the name for the output executable or dynamic link library. If no extension is supplied, an .exe file is generated; if the extension is .com, a .com file is created automatically, and if extension is .sys, a binary device driver format file is created. To skip this entry and cause OPTLINK to default to the executable type provided in a definition file or option switch, supply a comma or press the Enter key in the interactive mode. If no directive or option switch is supplied, the default file name (that of the first .obj file) with .exe extension will be created.
- The file name for map output. Using an Enter key while in the interactive mode suppresses all map output, unless previously configured with a /MAP suggested file name. See the related switch descriptions (/MAP, /XREF, /LINENUMBERS, or /DETAILEDMAP).
- Searches in order one or more library names to resolve any symbols
not defined in the input .obj files.
Wild card references can be used as with the obj entry.
The libraries are searched
in the order specified here. Use the "+" character
to separate multiple libraries.
Use the "+" continuation
character that comes before the end-of-line or before the comment
(#) string to extend past the end of the line.
The lib entry may be either a single file name or a pathname (with trailing "\") to a directory containing the libraries.
OPTLINK searches library files in the order that they are presented to it: that is, those named on the command line, and then those referenced by embedded commands in object modules. To locate each library file for which no path is specified, OPTLINK first searches the current directory followed by any paths specified in the LIB variable, and finally any paths named in the command line.
- The module definition file name. Optionally supplied, this file contains program linking information.
- One or more resource (.RES) file names. When supplied, OPTLINK performs the bind step of the Resource Compiler while linking. This eliminates the need to use a Resource Compiler to combine resources to the output file.
Examples of command line operationThe simplest method of using OPTLINK is to provide only the name of the .obj file to be used and accept the default suggestions for all other parameters:
C> LINK DUMP; OPTLINK Copyright (C) Digital Mars 1989-2001. All rights reserved.OPTLINK's sign-on copyright message is displayed on the console as shown above.
If the .obj file does not exist in the current directory or in any of the paths supplied by the environment variables, OPTLINK sends an error message:
C> LINK DUMPER; OPTLINK Copyright (C) Digital Mars 1989-2001 All rights reserved. DUMPER.OBJ Error 2: File Not Found DUMPER.OBJIf there is not a semicolon on a short command line, OPTLINK reverts to the interactive mode after all command line input is used, as the following examples indicate:
C> LINK DUMP,,MYMAP; OPTLINK Copyright (C) Digital Mars 1989-2001 All rights reserved. C> LINK DUMP,,MYMAP OPTLINK Copyright (C) Digital Mars 1989-2001 All rights reserved. Libraries and Paths: (.lib): Definition File: (.def): Resource Files: (.res)
Examples of interactive operationUse the Enter key at the Map File: prompt.
C> LINK OPTLINK Copyright (C) Digital Mars 1989-2001 All rights reserved. OBJ Files: (.obj): curset Output File: (curset.exe): Map File: (.map): Libraries and Paths: (.lib): Definition File: (.def): Resource Files: (.res)Using the "+" and the "#" comment characters causes multiple responses at the OBJ Files: prompt:
C> LINK OPTLINK Copyright (C) Digital Mars 1989-2001 All rights reserved. OBJ Files: (.obj): file1+ # this is the first object file OBJ Files: (.obj): file2+ OBJ Files: (.obj): file3 # this is the last Output File: (file1.exe): myfile Map File: (.map): Libraries and Paths: (.lib): mylib Definition File: (.def): Resource Files: (.res)Or use multiple file names on the same line:
C> LINK OPTLINK Copyright (C) Digital Mars 1989-2001 All rights reserved. OBJ Files: (.obj): file1 file2 file3 Output File: (file1.exe): myfile Map File: (.map): Libraries and Paths: (.lib): mylib Definition File: (.def): Resource Files: (.res)
Indirect File OperationFor more file names or option switches than the command line can hold, use indirect file operation to effectively eliminate any limit on the amount of information supplied to OPTLINK. For most complicated applications, this is the best choice.
OPTLINK uses the following syntax for indirect file operation:
LINK @indirfilewhere indirfile is the name of an indirect response file. During interactive operation at each prompt, the indirect response file has a number of text lines.
Example of indirect file operationIf the file lnklst contains the following lines:
DUMP NEWEXE MYMAP;then the following command lines are equivalent except that line length in an indirect file is unlimited, while DOS limits the command line to a maximum of 125 characters.
LINK @LNKLST LINK DUMP,NEWEXE,MYMAP;It is legal to use combinations of indirect file operation and either command line or interactive operation. OPTLINK accepts more than one indirect file specification. There are only two constraints: the indirect files that are combined must result in a valid sequence of responses and cannot be nested more than 10 deep.
Note: It is possible for a valid file name to actually begin with the "@" character. To keep such a file from being erroneously recognized by OPTLINK as an indirect response file, enclose the entire name of the file in quotation marks.
Command formatsAll three methods of providing command input use exactly the same format for input information.
File name usageOPTLINK uses the same file-naming conventions as those supplied by the host operating system. If a file extension is supplied, it must be separated from the name by a period. If none is supplied, OPTLINK assumes or creates a default value as described below.
The file name may be preceded by a pathname, which may be either absolute or relative and may include a drive specifier. If no path is specified, OPTLINK searches only the current working directory for the file or creates it in the current working directory. If a drive is specified, but no path, only the current directory for the specified drive is used.
Default file extensionsIf the file extension is omitted from a file name, OPTLINK assumes or creates a default extension for the file that is determined by the command with which the file name is associated. For instance, the default extensions for the file names supplied with the OBJ Files: prompt is .obj and for the Map File: prompt is .map. The defaults follow and are described later for each command that assumes or creates one. To refer to a file that has no extension and without using the default, add the "." separator after the file name to tell OPTLINK not to supply an extension.
|.def||Module Definition File|
|.exe||Executable files created by OPTLINK|
|.map||Listing of addresses generated by OPTLINK|
|.obj||Object files (in OMF format)|
|.cfg||Configuration file for default OPTLINK settings|
|none||Indirect command file used by OPTLINK|
Special file namesSince OPTLINK uses standard I/O for keyboard input and screen output, device names can be used in place of file names and you may redirect input and output. The device names are:
|AUX||refers to an auxiliary device (usually the same as COM1)|
|CON||refers to the console (keyboard input or display output)|
|PRN||refers to the printer (usually the same as LPT1) NUL a null (nonexistent) file; if given as an input name, returns end-of-file; if given as an output name, no output is generated|
LINK UTILITY; >LINK.LOG