This page describes the effect of each option switch recognized by OPTLINK.
Several option switches require numeric values. These are indicated by the suffix ":n" or "= n" within the syntax description. Separate the numeric value from the option by the appropriate colon or equals sign.
The numeric base defaults to decimal. If the value begins with a 0, its base is taken to be octal, and if it begins with 0x or 0X, hexadecimal is assumed. That is, the standard C language base convention is assumed by OPTLINK.
The following is an overview of OPTLINK switches. Either a "-" (hyphen) or a "/" (slash) must precede an option switch. Further descriptions of the option switches and their possible opposites are in "Using OPTLINK Option Switches" below.
|/ALIGNMENT||Segment alignment size|
|/BASE||Set the base address of the executable image|
|/BINARY||Generates a .sys file|
|/BYORDINAL||Export by ordinal|
|/CHECKSUM||Parsed and ignored|
|/CODEVIEW||Outputs CodeView debugger information|
|/COMDEFSEARCH||Specifies whether an undefined COMDEF causes a library search|
|/CPARMAXALLOC||Sets .exe maximum bytes to occupy in DOS RAM|
|/CVVERSION||Preserves OPTLINK's CodeView compatibility.|
|/DEBUG||Controls all debug information for files that follow|
|/DEBUGFILES||Controls debug information for specific files only|
|/DEBUGLINES||Controls debug line number information for files that follow|
|/DEBUGLOCALS||Controls debug local symbols information for files that follow|
|/DEBUGMODULES||Controls debug information for specific modules only|
|/DEBUGPUBLICS||Controls debug public symbols information for files that follow|
|/DEBUGTYPES||Controls debug type information for files that follow|
|/DEFAULTLIBRARYSEARCH||Searches default libraries named in .obj files|
|/DELEXECUTABLE||Deletes .exe upon encountering any linking errors|
|/DETAILEDMAP||Produces detailed map reports.|
|/DOSSEG||Controls segment sequence|
|/ECHOINDIRECT||Controls echoing of indirect response file input|
|/EMSMAXSIZE||Sets maximum EMS size|
|/EMSPAGEFRAMEIO||Gives permission to use EMS page frame for I/O|
|/EMSUSE40||Allow LIM 4.0 adherence|
|/ERRORFLAG||Controls error flag in segmented executable header|
|/EXEPACK||Performs run-length encoding (packs executable)|
|/EXETYPE||Specifies the target operating system|
|/FARCALLTRANSLATION||Converts intra-segment far calls to near|
|/FIXDS||Identical to the .def directive FIXDS|
|/FIXED||Fixes the executable image in memory|
|/GROUPASSOCIATION||Controls GROUP information found in .obj|
|/GROUPSTACK||Controls stack definition in .exe file header|
|/HEAP||Sets the size of the local heap|
|/HELP||Displays switch options|
|/IGNORECASE||Preserves and ignores case of all symbols|
|/IMPDEF||Generate .din file from EXPORTS section of .def file|
|/IMPLIB||Create .lib import library for .dll|
|/INFORMATION||Display status information throughout the link process|
|/LINENUMBERS||Outputs line number information in .map file|
|/LOWERCASE||Converts all symbols to lowercase|
|/MACHINE||Specifies the type of the target machine|
|/MAP||Controls information content in .map file|
|/NOLOGO||Suppresses OPTLINK's sign-on copyright message|
|/NONAMES||Eliminates name text for ordinal exports|
|/NULLDOSSEG||Outputs null bytes in the _TEXT segment|
|/ONERROR||Same as /DELEXECUTABLE|
|/PACKCODE||Combines segments of class CODE|
|/PACKDATA||Combines data segments where possible|
|/PACKFUNCTIONS||Performs "smart-linking" on code and data|
|/PACKIFNOSEGMENTS||Forces /PACKCODE on when no SEGMENTS directive|
|/PACKSIZE||Packs size for /PACKCODE and /PACKDATA|
|/PAGESIZE||Set /IMPLIB page size|
|/PAUSE||Provides time to swap disks while creating output|
|/PMTYPE||Specifies type of segmented output|
|/PROMPT||Specifies whether OPTLINK will prompt for more options|
|/RC||Like .def directive RC|
|/RELOCATIONCHECK||Ensures no relocation overlaps have occurred|
|/REORDERSEGMENTS||Performs segment reordering|
|/SCANLIB||Scans the LIB environment variable|
|/SCANLINK||Scans the LINK environment variable|
|/SILENT||Does not display linking status information|
|/STACK||Defines stack segment and/ or its size.|
|/STUB||Adds a stub file to the executable|
|/SUBSYSTEM||Sets Win32 subsyste|
|/TINY||Generates a .com file|
|/UPPERCASE||Converts all symbols to upper case|
|/VERSION||Adds a version number to the executable|
|/WARNDUPS||Warns of duplicate public symbols in .lib|
|/WINPACK||Build compressed output utilizing decompressing loader|
|/XMSMAXSIZE||Sets maximum XMS size|
|/XNOIGNORECASE||Treats EXPORT and IMPORT symbols as case significant|
|/XREF||Controls information content in .map file|
|/XUPPERCASE||Forces EXPORT and IMPORT symbols to upper case|
Unsupported Microsoft LINK switches
OPTLINK does not recognize the following Microsoft LINK switches:
/DSALLOC /DYNAMIC /HIGH /OLDOVERLAY /OVERLAYINTERRUPT /QUICKLIBRARY /r
OPTLINK parses and ignores the following Microsoft LINK switches:
/BATCH /CHECKABORT /CHECKEXE /NOEXTDICTIONARY /PADCODE /PADDATA /SEGMENTS /WARNFIXUP
Using OPTLINK Option Switches
This section describes the OPTLINK switches. By default, OPTLINK recognizes these switches.
While this section supplies the full name of each option switch, you need to supply only enough characters to uniquely identify it. These option switches are not case significant. Either a "-" or a "/" must precede an option switch. "Default" shows OPTLINK's assumptions before encountering any option switch or directive.
Default : /ALIGNMENT:16 (Win32 default is 512)
In the segmented .exe format, the ALIGNMENT value determines maximum file size because segments and resources are referenced by a 16-bit page number. Page size is set by ALIGNMENT, so if n is left at its default value of 16, the maximum file size will be 16* 65535 bytes, or 1 megabyte. To increase the file size limit, increase n. The value specified must be a power of 2.
When generating a conventional MS-DOS .exe files, this switch causes the .exe file header to be rounded up to the specified page size. n is the file header alignment size in bytes. Defaulting to 16 allows for the smallest .exe file size. Other linkers use a page size of 512, causing unnecessarily large .exe files. Some .exe post-processors (notably EXE2BIN) may require you to retain the 512-byte header size. The value specified must be a power of 2.
For 16-bit output, causes OPTLINK to move the name text for every exported symbol, designated by __export in source code, from the RESIDENT name table (which requires Windows memory) to the NONRESIDENT name table. Effectively, this option reduces memory requirements and load times for 16-bit programs. It also allows you to export more symbols from 16-bit .exe and .dll files, since the file format allows a maximum .exe header size of 64Kb, and RESIDENT names are part of that header. The NONRESIDENT table can be 65,535 bytes in size.
Use /BYORDINAL with /IMPDEF, /IMPLIB, and /NONAMES to optimize the size and speed of your 16-bit code. However, any additional modifications to entry points can cause ordinal changes that effectively necessitate rebuilding the entire application. To minimize the impact of this problem:
- Rebuild the entire application using /BYORDINAL, /IMPDEF, /IMPLIB, and /NONAMES. /IMPDEF creates a .din file (a .def include file) for the module being built. /IMPLIB generates the DLL's .lib file.
- For all subsequent builds, include the .din file (via the directive INCLUDE 'dinfilename') for the respective module, plus continue using all four of the above OPTLINK switches. This will eliminate ordinal problems by preserving the .def settings in the INCLUDE'd file.
Default : /NOCHECKSUMParsed and ignored.
Default : /NOCODEVIEWControls whether OPTLINK should include CodeView information within the output .exe file. CodeView expects such information to be present within applicable .obj files being linked. OPTLINK includes any available CodeView information for all object modules unless the options /DEBUG, /DEBUGCOVERAGES, /DEBUGFILES, /DEBUGLINES, /DEBUGLOCALS, /DEBUGMODULES, /DEBUGPUBLICS, or /DEBUGTYPES are supplied.
n specifies the CodeView major version format desired (applicable only with /CODEVIEW). For CodeView 2.x, enter 2, for CodeView 3.x, enter 3, and for CodeView 4.x, enter 4. For /CODEVIEW without a number, OPTLINK uses the default. OPTLINK automatically performs the CVPACK step when n is 4.
Default : /NOCOMDEFSEARCHSpecifies whether OPTLINK peforms a library search if it encounters an undefined COMDEF record.
Default : /CPARMAXALLOC:0xFFFFOnly valid when generating MS-DOS .exe files. This switch sets the maximum number, n, of 16-byte paragraphs needed by a DOS program to occupy when loaded in memory. This functionality is useful for reserving memory needed for other programs.
If the program requires more space, OPTLINK sets the allowable RAM usage to the actual amount required by the program. If you do not use this switch, OPTLINK sets the RAM requirement to its maximum possible value, causing the program to use all available RAM at run-time. Acceptable values are 1 to 65,535.
Default : /CVVERSION:4Enhance the Microsoft LINK drop-in replacement capability of OPTLINK. Your existing make files or other Microsoft LINK command sets may assume a different version of CodeView. By placing this switch in optlinks. cfg, you avoid making any changes to established make files.
n specifies the CodeView major version format desired (applicable only when using /CODEVIEW). For CodeView 2.x, enter 2, for CodeView 3.x, enter 3, and for CodeView 4.x, enter 4. When you enter /CODEVIEW without a number, OPTLINK uses the default. OPTLINK automatically performs the CVPACK step when you use 4.
By default, when directed to output debug information, OPTLINK includes all debug information content. Use /CODEVIEW to inform OPTLINK of the desired debugger format.
If you supply no modifiers, the switch controls the inclusion of all debug information for any subsequently supplied files. You can also supply any of the following modifiers:
Supplying /NODEBUG turns off debug information generation. The switch must appear before selectively including debugging information for specific object files. For example:
LINK/CO:4/NODEBUG obj1/DEBUGLINES obj2/DEBUG obj3;This forces OPTLINK to output full CodeView v4.x debugging information for file obj3 and only CodeView line number information for file obj2. It generates no debugging information for file obj1.
- Controls the inclusion of line number information in debug and map output for any subsequently supplied files.
- Controls the inclusion of local symbol information in debug output for any subsequently supplied files.
- Controls the inclusion of public symbol information in debug and map output for any subsequently supplied files.
- Controls the inclusion of type information in debug output for any subsequently supplied files.
LINK /CO:4/NODEBUG obj1/DEBUGLINES obj2/DEBUG obj3;This example generates full CodeView 4.x debugging information for file obj3 and only CodeView line number information for obj2. No debugging information is generated for obj1.
filename File name to include debug information. OPTLINK includes debugging information in all object modules in the named object or library file. Any file name specified without an extension defaults to the extension .obj. You can enter multiple file names, but you must include complete paths and an additional blank before the colon, ":myfile".
modname Object module name(s) to include debug information.
Default : /DEFAULTLIBRARYSEARCHControls how OPTLINK handles comment records in .obj file requesting a library search. The default setting causes OPTLINK to search all requested libraries. Otherwise, OPTLINK does no searching.
libname Applicable only with /NODEFAULTLIBRARYSEARCH.Specifies a library not to be searched. For example, "/NODEFAULTLIBRARYSEARCH:CLIBC" causes OPTLINK to ignore requests for CLIBC.LIB. You must provide a separate copy of the switch for each library name.
Default : /NODELEXECUTABLE
Controls whether OPTLINK should delete the .exe or .dll output file upon encountering any link error.
Default : /NODETAILEDMAPControls the amount of detail provided in the segment list produced at the beginning of the .map file. /DETAILEDMAP provides much more detail about segment type, which modules added, how many bytes to the segment, and where each module begins.
Default : /NODOSSEGControls .exe file segment sequence. When used, the segment sequence is: segments with a class name ending in CODE, then all segments not included in DGROUP, and, lastly, all segments of DGROUP (which will in turn be sequenced as BEGDATA, except BEGDATA, BSS and STACK, BSS, and finally STACK). Otherwise, segments appear in the sequence in which they are encountered while linking.
Default : /NOECHOINDIRECTControls the echoing of indirect response file input lines to the console.
Default : /EMSMAXSIZE:uses maximum availableFor 16-bit real mode hosted versions only. Controls the maximum number of kilobytes of EMS that OPTLINK uses. n set to 0 forces no EMS use.
Default : /EMSPAGEFRAMEIOFor 16-bit real mode hosted versions only. Most EMS memory systems are reliable when doing I/O to their page frame. Not quite so rare are disk cache programs that assume they are the only ones using the page frame and thus become confused when another program does. If you use one of these programs, supply /NOEMSPAGEFRAMEIO to stop the linker from doing I/O in the EMS page frame area. Normally, /EMSPAGEFRAMEIO is the fastest operation.
Default : /EMSUSE40Controls whether OPTLINK adheres to LIM 3. 2. Some EMS memory managers claim to be LIM 4.0 compatible but are not. If you encounter problems using EMS memory, try forcing the linker to comply to LIM 3.2 by supplying /NOEMSUSE40. If the problems go away, report the problem to your EMS driver vendor. This option is normally /EMSUSE40 (LIM 4.0) for fastest operation.
Default : /ERRORFLAGControls the setting of the error flag in a segmented-EXE or Win32 file header. When used, OPTLINK sets the flag when it encounters errors in the link process. Otherwise, OPTLINK does not set the flag even when it detects errors.
Default : /NOEXEPACK
Causes OPTLINK to run-length encode the generated .exe output file to reduce its size. It also compresses relocation entries to produce much smaller .exe files, especially in medium and large memory models. The EXEPACK technique is fully compatible with the /RC option of OPTLINK. Microsoft's Resource Compiler is not compatible.
n is applicable only with /EXEPACK on DOS executables. It specifies how many bytes at the beginning of the memory image are not to be compressed. This permits easier maintenance of patch, configuration, serialization, and similar areas in the .exe file. The default value is 0.Definition File Directives for information.
Default : /NOFARCALLTRANSLATIONCauses far calls to targets in the same segment to be converted to the equivalent combination of PUSH CS, NOP, and CALL NEAR. This can improve code performance and reduce .exe file size, since it eliminates the need for relocation entries. It also converts far jumps where possible. Supplying /FARCALLTRANSLATION forces /RELOCATIONCHECK.
Default : /NOFIXDSThis switch, applicable only to 16-bit Windows executables, does the same action as FIXDS directive in the .def file.
Default : /GROUPASSOCIATIONControls the use OPTLINK makes of GROUP information found in the .obj files. When used, OPTLINK uses all such information found in the files.
Default : /NOGROUPSTACKControls stack definition in the standard DOS .exe file header. When used, OPTLINK writes values into the header in a group-based format that does not require your programs to modify the value of SS after loading. This action is not compatible with the output of most high-level languages; their startup code assumes that the stack is wrong, and adjusts it back into DGROUP. Thus, it is recommended to use this switch only with assembly language programs. Otherwise, OPTLINK writes these values in physical segment:offset form just as other linkers do, which effectively takes SS out of DGROUP. Definition File Directives for information.
Default : /IGNORECASEForces OPTLINK to preserve but ignore the cases of identifiers and symbols, including the optional symbol table that may be appended to the output file. Only one of /IGNORECASE, /NOIGNORECASE, /LOWERCASE, and /UPPERCASE can be in effect for any specific run of OPTLINK.
Default : /SILENTThis switch causes OPTLINK to display status information throughout the link process. It is the opposite of /SILENT.
Default : /NOLINENUMBERSControls whether line-number information shall be contained within the .map file.
Default : /IGNORECASEForces OPTLINK to convert symbols to lowercase. Only one of /IGNORECASE, /NOIGNORECASE, /LOWERCASE, and /UPPERCASE can be in effect for any specific run of OPTLINK.
Default : /NOMAPCauses the addition of public symbols to the .map file. The /MAP option normally outputs the symbol twice:sorted alphabetically and by increasing addresses. It accepts any of the following modifiers: ADDRESS Outputs only the increasing address sort listing. FULL Produces detailed maps as does the /DETAILEDMAP switch. GROUP Displays the GROUP column on the report. NOGROUP Does not display the GROUP column. /MAP defaults to :NOGROUP.
Default : /NULLSDOSSEGControls the generation of 16 null bytes at the beginning of the _TEXT segment in DOSSEG mode. The Microsoft run-time usually requires this.
Default : /NODELEXECUTABLECauses OPTLINK to delete the .exe or .dll output file if any link error occurs. Normally the .exe file is not deleted upon an error.
Default : /NOPACKCODECauses OPTLINK to combine any segments of class name ending in CODE, to a maximum size of n bytes. The main purposes of this are:
- To improve operation of the /FARCALLTRANSLATION option, since more targets will be in the same segments, and
- To reduce the segment count for segmented .exe files. Some debuggers also function better when the segment count is kept low. /PACKCODE causes segments to be logically combined (packed) into larger physical segments.
Default : /NOPACKDATACauses OPTLINK to combine data segments if possible, to produce larger, but fewer, data segments. /PACKDATA causes segments to be combined (packed) into larger physical segments. Note Applicable only with /PACKDATA is n: the maximum segment size of groups. /PACKSIZE controls the default value. Values of 8192 or 16384 may provide better performance for large applications because the segments being swapped, discarded, and reloaded are smaller.
Default : /PACKFUNCTIONSEnables true smart linking of object files containing COMDAT records. OPTLINK retains only referenced COMDAT records. OPTLINK is fully recursive in this support; it removes unnecessary COMDATs and library modules from the executable.
Default : /PACKIFNOSEGMENTSForces /PACKCODE on Windows output if the .def file does not use a SEGMENTS directive. MS-LINK has an undocumented feature/bug in which /PACKCODE:65500 is enabled for Windows .exe/. dlls if the .def file does not use a SEGMENTS directive. This option is enabled by default for compatibility. You may want to disable it.
Default : /PACKSIZE:65500Sets the default size (in bytes) for the /PACKDATA and /PACKCODE switches.
Default : /PACKSIZE:16Sets the page size for the /IMPLIB link option. The default value is 16, which allows a .lib file of up to 1Mb in size. n must be a power of 2 greater than or equal to 16.
Default : /NOPAUSEAllows swapping of diskettes just before OPTLINK writes binary output data.
Default : /PMTYPE:PMThis switch, used only when producing segmented executable or .dll output, requires one of three type specifiers. PM The application is Windows or PM and can execute only in the Windows or PM environment. For Windows, this eliminates the need to use RC if there are no resources. This format is the default output from OPTLINK.
Default : /PROMPTDetermines whether OPTLINK prompts for input if additional link switches were expected (that is, if no semicolon (;) appeared at the end of the list of switches).
Provides an alternative to the RC statement in the .def files. The .res file is assumed to be the same primary name as the .exe or .dll. Effective only when the switch is supplied. There can be multiple instances of /RC.
This switch accepts the same eight options (each preceded by "-", a hyphen) accepted by the RC directive in the .def file. They are:
|-e||Creates a driver that uses EMS memory|
|-k||Keep segments in .def file order; does not sort or create a fast-load section|
|-l||Creates an LIM 3.2 EMS application|
|-m||Sets multiple instance flag|
|-p||Create a private library (PRIVATELIB).|
|-t||Creates a protected-mode-only application (PROTMODE).|
|-30||Tags the executable as requiring Windows 3.0 or later to run|
|-31||Tags the executable as requiring Windows 3.1 or later to run|
filename is the optional file name. You can use /RC without a filename to mark .exe or .dll files as valid Windows files (ignore the file-not-found warning that results). It also causes preload segment reordering to occur.
Default : /RELOCATIONCHECKThis switch causes OPTLINK to do extra processing to ensure that no relocation overlaps occur. Although rare, such overlaps can occur under the following circumstances: when initializing common blocks in more than one module or ORGing back over a relocation item in assembly language or when a translator error occurs.
Default : /NOREORDERSEGMENTSAllows OPTLINK to perform segment reordering. First, it orders all grouped segments so that segments belonging to a particular group are contiguous. It then orders all non-grouped segments so that code segments (classes ending in CODE) are together, and, therefore, all data segments are together. This allows the maximum benefit from /PACKCODE and /PACKDATA.
Default : /SCANLIBForces OPTLINK to scan the LIB environment variable for additional library paths. You can use the LIB environment variable to aid in the drop-in-replacement use of OPTLINK. This option works only in the optlinks. cfg file, since OPTLINK scans environment variables before scanning the command line.
Default : /SCANLINKForces OPTLINK to scan the LINK environment variable for additional option switches. You can use the LINK environment variable to aid in the drop-in-replacement use of OPTLINK. When supplied, OPTLINK scans LINK before scanning the OPTLINK environment variable. This option works only in the optlinks. cfg file, since OPTLINK scans environment variables before scanning the command line.
Default : /SILENTThis switch causes OPTLINK to suppress status information throughout the link process. It is the opposite of /INFORMATION. STUB Module Definition File directive.
Default : /SUBSYSTEM:CONSOLEThis option works like the SUBSYSTEM Module Definition File directive.
This switch causes OPTLINK to generate a .com file instead of an .exe file. The .com file automatically starts at offset 0100h in the code segment. To generate memory image files that start at other locations, use the /BINARY option switch.
Default : /IGNORECASE
Forces OPTLINK to convert symbols to upper case. Only one of /IGNORECASE, /NOIGNORECASE, /LOWERCASE, and /UPPERCASE can be in effect for any specific run of OPTLINK.
Puts the specified version number in the executable file. nn is the major version number; mm is the minor version number.
Default : /NOWARNDUPS
Forces OPTLINK to output warning messages upon encountering duplicate library symbols. Very useful in debugging complex applications.
Default : /NOWINPACK
Compresses 16-bit Windows .exe or .dll output files and adds a decompressing loader to the file. /WINPACK typically decreases the size of .exe and .dll output files by 50%. This option requires the use of OPTLINK's /RC link option (rather than using other resource binders).
To obtain maximum compression:
- For best results, pack all the executable files and DLLs that make up an application.
- Turn off debug output.
- Use /PACKDATA:0 for packing to full 64K data segments.
- Use the largest /PACKSIZE possible. 16K is good if you need small segments. 64K is best for compression.
- Use a smaller /ALIGNMENT size.
- Export and import by ordinal number, and eliminate name text. See the /BYORDINAL and /NONAMES link options.
If your application contains .res files, you must use OPTLINK to bind them to the packed executable. /WINPACK's decompressing loader must be segment number 1 in an .exe or .dll file, leaving 253 segments available for the application (one less than without /WINPACK). All segments are compressed, so if some value or string is modified after linking (for example, a product serial number), it will have to be located somewhere other than a code or data segment, perhaps in a resource.
For DLLs that cross-reference one another (for example, A. DLL references items in B. DLL, and B. DLL references items in A. DLL), neither DGROUP nor the code segment containing the start address can contain references to a DLL it cross-references. Since /WINPACK compresses segments and relocations but not resources, the output file may be made even smaller by running it through another compression program after linking.
Default : /XMSMAXSIZE uses maximum available
Controls the maximum number of kilobytes of XMS memory that OPTLINK uses. n set to 0 forces no XMS use.
Default : /XNOIGNORECASE
Forces OPTLINK to treat EXPORT and IMPORT symbols as case significant. Only one of /XNOIGNORECASE and /XUPPERCASE can be in effect for any specific run of OPTLINK.
Note: By default, the case of IMPORT and EXPORT symbols is significant. (In previous versions of Digital Mars C++, the default was /XUPPERCASE.) If a working application now generates run-time errors pertaining to undefined symbols, the case of symbols in some modules or libraries might be mismatched. Try rebuilding the application using the /UPPERCASE option, or declare the EXPORT and IMPORT symbols in definition files the same way they appear in object files.
Default : /NOXREF
Controls whether OPTLINK adds cross reference information to the .map file. That is, for every global symbol, OPTLINK lists the module name where defined, followed by every other module name that referenced it.
Default : /XUPPERCASE
Forces OPTLINK to convert EXPORT and IMPORT symbols to upper case. Only one of /XNOIGNORECASE and /XUPPERCASE can be in effect for any specific run of OPTLINK.
Identical to /HELP. Displays a list of available switches. In the list, those characters required to identify each switch appear in uppercase, while characters appearing in lowercase are optional and may be omitted.