|
Tools BCC CHMOD CL COFF2OMF COFFIMPLIB DMC DIFF DIFFDIR DUMP DUMPOBJ DUMPEXE EXE2BIN FLPYIMG GREP HC IMPLIB LIB LIBUNRES MAKE MAKEDEP ME OBJ2ASM PATCHOBJ RC RCC SC SHELL SMAKE TOUCH UNMANGLE WHEREIS Compiling Compiling Code C Implementation C++ Implementation Language Extensions Mixing Languages Assembly Language Inline Assembler Optimizing Code Numerics Programming Regular Expressions Acrtused Pragmas Precompiled Headers Predefined Macros Warning Messages Error Messages Runtime Messages Linking Optlink Switches Module Definition Files Operation and Design Error Messages Win32 Programming Win32 Programming DOS and Win16 Programming Memory Models 16 Bit Pointer Types and Type Modifiers Handle Pointers DOS DOS 32 (DOSX) Win16 Win16 DLLs Win16 Prolog/Epilog Virtual Memory For 640Kb DOS C/C++ Extensions Contract Programming __debug statement __debug declaration Dynamic Profiling Embedding C in HTML Porting to DMC++ Switching to DMC++ from Microsoft from Borland Porting Guide |
OPTLINKOPTLINK, 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 can be 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. OverviewOPTLINK 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. 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:
These features combine to create an environment in which you can
create large programs, despite apparent memory constraints.
Option switch precedenceSwitches are read and processed in lexical order. Any subsequent switch overrides any previous switch setting.
ConfigurationTo 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.Environment VariablesThe 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.
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
Optimizing Linker PerformanceFor fast execution of the linker, follow these guidelines.
Operational ModesOPTLINK can get commands from the command line, interactively, or from an 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 is read by OPTLINK for its linker input.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:
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.
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:
LINK UTILITY; >LINK.LOG |