www.digitalmars.com [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

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:

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:

Setup of the OPTLINK Linker

Option switch precedence

Switches are read and processed in lexical order. Any subsequent switch overrides any previous switch setting.

  1. The optlinks.cfg configuration file.
  2. The LINK environment variable.
  3. The OPTLINKS environment variable.
  4. 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.