12.2 LINK Output Files

LINK is a bound application that runs under both DOS and OS/2 and can create executable files for DOS, OS/2, or Windows. You do not have to run LINK under OS/2 to create OS/2 applications, or under DOS to create DOS programs. The kind of file produced is determined by the way the source code is compiled and the information supplied to LINK, not the operating system LINK runs under.

A program that runs under DOS is called an executable file or application. A program or DLL that runs under Windows or OS/2 is called a segmented executable file. LINK creates the appropriate file according to the following rules:

If a module-definition file or import library is not specified and the object files and libraries do not contain export definitions, LINK creates an application that runs under DOS.

If a module-definition file containing a LIBRARY statement is specified, LINK creates a DLL for Windows or OS/2.

If any other form of module-definition file is specified, or if any of the object files contains an exported definition, LINK creates an application to run under Windows or OS/2.

LINK looks for the default run-time libraries named in the object files. Default libraries can be real or protected mode. (The mode is usually set when the language product is installed.) Protected-mode libraries contain export definitions. If LINK finds protected-mode default libraries, the output file will be a segmented executable file rather than a DOS file.

The file OS2.LIB is an import library. Linking with OS2.LIB produces an OS/2 application or DLL. When you use a Microsoft high-level language to compile for protected mode, the compiler automatically specifies OS2.LIB as a default library.

LINK's output is either an executable file or a DLL. For simplicity, this chapter sometimes refers to this output as the “main file” or “main output.”

Summary: Map files list the segments and symbols in a program.

LINK also creates a “map” file, which lists the segments in the executable file. The /MAP option adds public symbols to the map file, and the /LINE option adds line numbers.

Summary: LINK produces other files when certain options are used.

Other options tell LINK to create other kinds of output files. The /INCR option creates .ILK and .SYM files for incremental linking with ILINK. LINK produces a .COM file instead of an .EXE file when the /TINY option is specified. The combination of /CO and /TINY puts debugging information into a .DBG file. A Quick library results when the /Q option is specified. For more information on these and other options, see Section 12.5, “LINK Options.”