[Home]
[Search]
[Contents]
Introducing OPTLINK
OPTLINK, the Digital Mars linker, links object files and libraries to
produce an executable program or DLL for DOS, Windows 3.x, or Win32.
For simple programs, the link step is typically run automatically
by the compiler. For more complex applications that need close control
over how the program is linked, run OPTLINK as a separate step.
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.
What's in This Chapter
- An overview of OPTLINK
- How OPTLINK works
- How OPTLINK is configured
- How OPTLINK uses environment variables
What is OPTLINK?
OPTLINK is a super-fast, high-capacity program linker. It is designed
for use by professional programmers to efficiently create both
standard .exe and .com executable files for use with MS-DOS and
segmented .exe files (segmented executable) and dynamic link
libraries (.dll) for use with Windows and Win32 in significantly
less time than is required by other linkers.
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.
What does OPTLINK do?
OPTLINK combines program and library 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 .obj module libraries. The output files produced have all
address assignments resolved and are in one of three standard
formats:
- 16 bit DOS .exe relocatable executable MZ format (MSDOS)
- 16 bit .com/.sys/.bin memory image format (MSDOS)
- 16 bit segmented .exe NE format (Windows 3.x)
- 32 bit .exe PE format (PE) (DOSX, Win32)
How OPTLINK works
All available memory is used by OPTLINK when creating your
executable program. In 16-bit programs, the number of program
description objects that can be accommodated is limited to 64KB for
each kind of object (PUBLIC, LIBRARY, SEGMENT, and so on). If
memory space is inadequate, the program descriptions are
automatically paged out to disk files which are then deleted once the
link process completes.
These features combine to create an environment in which you can
create large programs, despite apparent memory constraints.
OPTLINK Features
Although compatibility with existing linkers was a prime objective in
the design of OPTLINK, the product sets itself apart from other
linkers with a number of exclusive features. OPTLINK features
include:
- Speed
Executes faster than any other method for creating
executable files. Removal of duplicate records (CVPACK)
is built in.
- Capacity
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.
Setup of the OPTLINK Linker
Option switch precedence
Switches 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.
OPTLINK configuration
To specify default operating parameters not available through the
IDDE, modify the file named optlinks.cfg. You can supply
option switches that you may regularly use or desire as default.
When called, optlinks. cfg, an ASCII file, is read by OPTLINK
from its home directory, unless optlinks.cfg already exists in the
current directory. OPTLINK recognizes the "#" as a comment
character and thus ignores the remainder of the line.
DOS environment variables
The environment variable names recognized are LIB, TMP, LINK,
OPTLINKS and OBJ. OPTLINK also searches the PATH environment
variable to locate certain executable files. The environment variables
are typically defined in autoexec.bat or another batch file.
- 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.
For example, to select the linker option /IGNORECASE as the
default, the following command could be used:
set OPTLINKS=/IG
The environment variables can be overridden by command line
input. Every switch can be changed, since it has an opposite.
DLL Version of OPTLINK
The DLL version of OPTLINK is linknd.dll.
Optimizing Linker Performance
For fast execution of the linker, follow these guidelines.
DPMI Version of OPTLINK
For DOS hosted linking, we recommend you use the DPMI version
of OPTLINK, link.exe. The DPMI version displays DPMI in the
sign-on message when you invoke it, and it executes significantly
faster than the real mode version of OPTLINK, lnkr.exe. DPMI,
which large applications may require for linking, is available from
virtual memory managers like the Windows DOS box or Qualitas
386MAX Version 7.
If DPMI memory management is not available, link.exe will
automatically run the real mode version of OPTLINK.
Optimizing Linker Performance
For 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 you are 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.