Linking an application should always be done under the control of the LF95 driver; it is not necessary to separately invoke LINK.EXE. Linking will occur automatically, as long as the -c option is not specified. Any combination of source, object, library, and resource files can be provided on the LF95 command line, and LF95 will first compile files using the Fortran or resource compiler, depending on the extension of the specified file, and then invoke the linker.
During the link phase, the driver submits object files, object file libraries, and compiled resource files to the linker. The linker reads individual object files and libraries, resolves references to external symbols, and writes out a single executable file or dynamic link library. The linker can also create a map file containing information about the segments and public symbols in the program.
Object files are processed in the order in which they appear on the command line. If an object file has no path information, it is searched for first in the current directory, and then in any directories listed in the LIB environment variable.
An object file that is created when compiling a module is treated like any other object file. When linking a program that uses a module, the module's object file must be provided to the linker along with the rest of the program. This can be done in one of several ways:
No special switch is needed to indicate that a library is to be linked, the driver is able to infer that the file is a library due to the .lib extension. A library should be specified by listing the library file name with the .lib extension on the command line in the same way that a source or object file is specified.
Libraries are searched in the order in which they appear on the LF95 command line. If multiple libraries contain the same object, the first object encountered is linked, and any duplicate objects in subsequent libraries are ignored.
If a library file is specified without path information, the linker looks for it in the following order:
In addition to the link options described in the reference, Microsoft-specific link options which are not documented here may be used on the LF95 command line. These options should be specified with a hyphen (-), not a slash (/) and are sent to the linker unmodified. Note that some linker options will not necessarily apply to Fortran objects.