[Home]
[Search]
[Contents]
Using OPTLINK
This chapter describes the operational aspects of using OPTLINK.
What's in This Chapter
- OPTLINK's operational modes.
- Using OPTLINK from the command line.
- Using OPTLINK interactively.
- Using OPTLINK from a command file.
Operational Modes
OPTLINK's available operational modes are: command line,
interactive, and indirect file.
All input on the command line should be in a series of parameters.
For the interactive mode at a console, use link. exe. Using indirect
file operation, you can enter prompt-like responses into a file. The
specific file name is passed to OPTLINK on the command line and
thus read by OPTLINK for its linker input.
In all modes of operation, OPTLINK requires that you provide the
same kinds of control information, in the form of OPTLINK
commands. This chapter describes the methods by which your
commands may be transmitted to OPTLINK.
Command Line and Interactive Operation
Command line operation of OPTLINK uses the following syntax:
LINK obj[,out[,map[,lib[,def[,res]]]]]
For interactive operation simply input LINK followed by any option
switches, which are described later, and press Enter. OPTLINK then
prompts you for responses (option switches may be entered after
any response).
OPTLINK parameters include the following:
- obj
- 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
next line.
You may use ambiguous names wild-card characters "?" and "*". 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, you may use specific data or a "+" character to
invoke the default choices. If neither is supplied, operation switches
to the interactive mode, and you are prompted for the remaining
inputs. The "#" character tells OPTLINK to ignore the rest of the
comment characters following on that line.
- out
- 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, 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.
- map
- 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)
later in this manual.
- lib
- Searches in order one or more library names to resolve any symbols
not defined in the input .obj files.
You may use wild card
references as with the obj entry. The libraries are searched
in the order specified here. You may use the same separators as you
used for the obj portion apply. You may 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.
- def
- The definition file name.
Optionally supplied, this file contains
program linking information. This file type and its contents are
described later in this manual.
- res
- 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.
Also like the .OBJ entry, wild-card references may be used. The
libraries will be searched in the order specified. The same separators
used for the obj portion apply, and the res entry may also be
extended past the end of a line by means of the continuance
character (+) immediately before the end of line or comment (#)
string.
Examples of command line operation
The 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-94
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-94
All rights reserved.
DUMPER.OBJ
Error 2: File Not Found DUMPER.OBJ
If you do not use 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-94
All rights reserved.
C> LINK DUMP,,MYMAP
OPTLINK Copyright (C) Digital Mars 1989-94
All rights reserved.
Libraries and Paths: (.lib):
Definition File: (.def):
Resource Files: (.res)
Examples of interactive operation
Use the Enter key at the Map File: prompt.
C> LINK
OPTLINK Copyright (C) Digital Mars 1989-94
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-94
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-94
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 Operation
If your application requires more file names or option switches than
the command line can hold, you can use indirect file operation to
effectively eliminate any limit on the amount of information you can
supply to OPTLINK. For most complicated applications, this is the
best choice.
OPTLINK uses the following syntax for indirect file operation:
LINK @indirfile
where 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 operation
If 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 formats
All three methods of providing command input use exactly the same
format for input information.
File name usage
OPTLINK 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 extensions
If 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
- Definition file describing desired output
- .exe
- Executable files created by OPTLINK
- .lib
- Library files
- .map
- Listing of addresses generated by OPTLINK
- .obj
- Object files (in OMF format)
- .cfg
- Configuration file for default OPTLINK settings
- .res
- Resource files
- none
- Indirect command file used by OPTLINK
Special file names
Since OPTLINK uses standard DOS functions for keyboard input and
screen output, you may use device names 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
To redirect OPTLINK input and output from and to files, use the
standard redirection keys. For example, the following command
redirects OPTLINK output (including all prompts) to file link.log
instead of to the screen:
LINK UTILITY; >LINK.LOG