12.3.6 Examples

The following examples illustrate various uses of the LINK command line.

Example 1

LINK FUN+TEXT+TABLE+CARE, , FUNLIST, XLIB.LIB;

This command line links the object files FUN.OBJ, TEXT.OBJ, TABLE.OBJ, and CARE.OBJ. By default, the executable file is named FUN.EXE, because the base name of the first object file is FUN, and no name is specified for the executable file. The map file is named FUNLIST.MAP. LINK searches for unresolved external references in the library XLIB.LIB before searching in the default libraries. LINK does not prompt for a .DEF file because a semicolon appears before the deffile field.

Example 2

LINK FUN, , ;

This command produces a map file named FUN.MAP because a comma appears as a placeholder for the mapfile field on the command line.

Example 3

LINK FUN, ;

LINK FUN;

Neither of these commands produces a map file, because commas do not appear as placeholders for the mapfile field. The semicolon (;) terminates the command line and accepts all remaining defaults without prompting; the prompting default for the map file is not to create one.

Example 4

LINK MAIN+GETDATA+PRINTIT, , MAIN ;

This command links the files MAIN.OBJ, GETDATA.OBJ, and PRINTIT.OBJ into a DOS executable file because no module-definition file is specified. The map file MAIN.MAP is created.

Example 5

LINK GETDATA+PRINTIT, , , , MODDEF

This command links GETDATA.OBJ and PRINTIT.OBJ into a DLL if MODDEF.DEF contains a LIBRARY statement. Otherwise, it links them into a segmented executable file for OS/2 or Windows. LINK creates a map file named GETDATA.MAP.